Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search and Replace

Status
Not open for further replies.

darfader

Programmer
Aug 6, 2003
38
GB

Hi,

I am currently opening a file and using this command

:%s / /;/g

replacing a tab with a semi-colon,

I was just wondering if I could do it without manually opening the file ?


tia,
 
You could do sed 's/ /;/g' filename > newfile

Greg.
 
you can use also vi:
vi +'%s/ /;/g|wq' x.txt
or
vi +'%s/ /;/g|wq newfile' x.txt

PM
 
I got lazy, found a package called "rpl" which does replaces very nicely and easily.

IBM Certified Confused - MQSeries
IBM Certified Flabbergasted - AIX 5 pSeries System Administration
MS Certified Windblows Rebooter
 
thanks chaps,

I think I'll stick with the SED one, I have just read that if I wanted to do more than one at time, I could use the -e flag :)

 
same thing you can do in vi, look at `|'.

vi +'command1|command2|...|command_n' file


PM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top