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!

Commiting changes to SED outpput

Status
Not open for further replies.

dsm325

Technical User
Apr 4, 2001
29
US
Please help,

I am trying to delete a word in several files, and I am not succeeding:

sed 's!/data!! *.sh

I also tried sed 's/\/data//g'

The changes do printout on the screen but not when I cat or vi the file.

How can I commit these changes, thanks much
 
Doing something like
Code:
  sed 's!/data!! *.sh
processes all your *.sh files, but combines them all into a single output to the screen.

You need to loop over the files, and capture the output of each one
Code:
# for all *.sh files
for i in *.sh ; do
  mv $i $i.bak                 # make a backup file
  sed 's!/data!!' $i.bak > $i  # sed the backup, and put the results in the original
done

After you're happy all went well, then you can delete all the *.sh.bak files.


--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top