LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-19-2006, 04:32 AM   #1
procfs
Member
 
Registered: Jan 2006
Location: Sri Lanka
Posts: 651

Rep: Reputation: 34
How to replace a full column in vi


Hi

How do I replace a full collum (each row is not identical) in vi

or

How can I delete files older than a date



Regards
Asanka
 
Old 07-19-2006, 09:02 AM   #2
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
As for changing columns, if you don't have to do it in an editor, you can use awk instead. Awk was created for just this sort of task.

To delete files older than a certain time, first create a dummy file which represents that time.
Code:
touch -t 200607191013.22 compared_time
Then you can use this as a comparison value in the find command.
Code:
find . -not -newer compared_time -delete
Please try this code in a safe place before using it to really delete files (e.g. replace -delete with -print in the find command).
 
Old 07-19-2006, 09:30 AM   #3
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
In vim, you can use Ctrl-v in order to select a column.
 
Old 07-19-2006, 09:49 AM   #4
lockpicker
Member
 
Registered: Feb 2006
Location: Sikkim Manipal Institute of Technology, Sikkim
Distribution: Slackware 10.2
Posts: 80

Rep: Reputation: 15
Since you're going about with vim, try using vitutor to get your hands working properly with vim!!
 
Old 07-19-2006, 10:42 AM   #5
koobi
Member
 
Registered: Jun 2006
Location: Colombo, Sri Lanka
Distribution: Ubuntu
Posts: 103

Rep: Reputation: 15
well you can select a whole column by:
Code:
<esc>v}
then you can hit <esc>p to paste what's in your buffer like you would normally.
 
Old 07-19-2006, 11:22 AM   #6
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Good old vi can replace a column (space separated) by a constant string like this:
Code:
:g/^\([^ ]*\) \([^ ]*\) \(.*\)$/s//\1 new_column_2 \3/
 
Old 07-19-2006, 09:14 PM   #7
procfs
Member
 
Registered: Jan 2006
Location: Sri Lanka
Posts: 651

Original Poster
Rep: Reputation: 34
Hay guys thanks

Regards

Asanka
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
In SSH, how to replace a full domain name with an alias zbinwu Linux - Newbie 7 04-23-2012 07:14 AM
ls column description anjanesh Linux - Newbie 5 01-04-2006 04:45 AM
Need to replace full harddrive with new, larger harddrive pearlr Linux - Newbie 1 01-02-2004 12:59 PM
problem in perl replace command with slash (/) in search/replace string ramesh_ps1 Red Hat 4 09-10-2003 01:04 AM
add new column Eddie9 Linux - General 2 04-09-2002 12:05 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration