![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| repeat pattern without using excel | ajp7701 | Shell Programming and Scripting | 3 | 03-14-2008 09:28 PM |
| Repeat last entered command ? | vilius | Shell Programming and Scripting | 5 | 09-25-2007 03:15 AM |
| to copy and repeat | falcondown01 | Shell Programming and Scripting | 4 | 09-07-2007 05:15 PM |
| Limitations of awk? Good idea? Bad idea? | yongho | Shell Programming and Scripting | 2 | 06-08-2005 02:18 PM |
| Repeat Commands | dereckbc | UNIX for Dummies Questions & Answers | 6 | 01-04-2005 08:15 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
any idea to repeat a action in VI
Any idea to repeat an action to all the lines in vi...
suppose i want to delete the first word from all the lines in VI .. how would i do it ? in general i am also looking for a way to apply a action to all the lines in VI .
__________________
If u r not confused today , u r not thinking clearly!!! |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Hi,
If you want to repeat an action, you use the . (dot)... Check this out for more ! http://csep1.phy.ornl.gov/unix_guide...00000000000000 |
|
#3
|
||||
|
||||
|
I know that you can use the "." period for repeating the same action...
If you use the dw command in vi to remove a word, then use "." it will repeat the action. then navigate down with the j key. If you have 9 or less columns in a file awk will work great... awk '{ print $2, $3, $4, $5, $6, $7, $8, $9 }' < file.in > file.out If you have lines of text with more than 9 fields. I cant think of a way to do it for the whole file without calling a program from the :sh prompt.
__________________
My brain is your brain |
|
#4
|
|||
|
|||
|
Any idea to apply the same action to the multiple lines in a one go ... Suppose i delete 2 words from a line and want to repeat the same action to the next 1000 lines in a one go ???
Thanks
__________________
If u r not confused today , u r not thinking clearly!!! |
|
#5
|
||||
|
||||
|
Hi,
vi is a very powerful tool. explore it to do something over a number of lines you need to use :<startline>,<endline> command besides this vim provides recording. however, i wud suggest you that try to use some external scripts like awk, sed etc to do such things.
__________________
War doesnt determine who is right, it determines who is left |
|
#6
|
|||
|
|||
|
Q1:
Example1: cat testfile 111 222 333 444 aaa bbb ccc ddd 111 222 333 444 In vi mode, step to remove first word. press 'Esc' : prompt appear then type %s/.[^ ]* *// "%" is represented to whole document Example2: cat testfile 111 222 333 444 aaa bbb ccc ddd 111 222 333 444 In vi, step to remove lines selectively
__________________
tikual :) |
|
#7
|
|||
|
|||
|
oh sorry, press wrong key to post the previous message.
The remains are shown as follows: press 'Esc' : prompt appear then type .,1000s/.[^ ]* .[^ ]* // it will remove first two words of each line from "current line to line 1000"(.,1000).
__________________
tikual :) |
|||
| Google The UNIX and Linux Forums |