I have a file with the several of the following create statements. I want to edit and delete everthing between 'STORAGE' and 'DEFAULT', can someone please tell me how I can either use vi, SED or any other unix tool to achieve this task?
Thanks a lot in advance.
The -F option tells awk to treat "STORAGE" as a field separator.
Using substr+index function we take the after-"DEFAULT" part
In this example, t is the filename of the source
awk -F STORAGE '{
printf $1
printf "----- everything you want to put between STORAGE and DEFAULT -----"
print substr($2,index($2,"DEFAULT")+8)
}' t
Check out if u can FTP your file to any windows desktop environment... edit and put it back again !
There is no short cut in UNIX to remove lines
between STORAGE and DEFAULT for the whole file.
Still u can delete few lines together
in UNIX as follows ndd where 'n' stands for
the number of lines you want to delete
ex., 10dd deletes 10 lines from the cursor
position.
Search for the word STORAGE, then delete till
rest of the line by pressing D (pls note
vi is case sensitive too!). Delete the lines
following it till DEFAULT, as said before.
NOTE :
dd - deletes a line
5dd - deletes 5 lines
dw - deletes a word
D - deletes till end of line from the
cursor position
/findwhat - will search down for the word 'findwhat'
in the file from cursor position
May not be what u want.... but probably
would help u in editing ur file.