LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to replace a full column in vi (https://www.linuxquestions.org/questions/programming-9/how-to-replace-a-full-column-in-vi-465466/)

procfs 07-19-2006 04:32 AM

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

taylor_venable 07-19-2006 09:02 AM

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).

tuxdev 07-19-2006 09:30 AM

In vim, you can use Ctrl-v in order to select a column.

lockpicker 07-19-2006 09:49 AM

Since you're going about with vim, try using vitutor to get your hands working properly with vim!!

koobi 07-19-2006 10:42 AM

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.

jlliagre 07-19-2006 11:22 AM

Good old vi can replace a column (space separated) by a constant string like this:
Code:

:g/^\([^ ]*\) \([^ ]*\) \(.*\)$/s//\1 new_column_2 \3/

procfs 07-19-2006 09:14 PM

Hay guys thanks

Regards

Asanka


All times are GMT -5. The time now is 05:34 PM.