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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to edit a file without opening it (in single command line)?

Status
Not open for further replies.

suhaimi

Technical User
Aug 3, 2001
71
0
0
US
Hi all,
Is there a way to edit/update a text file without having to open and edit or pipe it to another file?
I've tried this command but it does not work.....
eq. vi +:g/TEST/s//Test/g +:wq! abc.log

Please help...
Thanks,
Suhaimi
 
Hi,

I give you a tips which can maybe help you... The following command allows to add a line of text at the end of a file:

# echo "the text..." >> fileName

orx57
 
Argh!

Forgiveness!

I read too fast the question. My answer will not be to you of a big help... I do not know if the edition which you wishes is possible without opening the file.

Kind regards,

orx57
 
I think you need to use sed :-

The sed utility is a stream editor that reads one or more text files, makes editing changes according to a script of editing commands, and writes the results to standard output.
The script is obtained from either the script operand string, or a combination of the option-arguments from the -e script and -f script_file options. TandA

Day by day, the penguins steal my sanity.
 
Hi,

for f in <regexpr(files)>
do
sed -e 's/<old>/<new>/g' $f > tmp
mv tmp $f
done

@+

orx57
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top