Darshan M Darshan M - 1 year ago 60
Bash Question

Rename the footer content in the data file(.csv file) from shell script

I get a .csv file, in which the last line has the footer value
For Example:

**WOR_FOOTER_20160705100007_000000010_WOR_896312_20160705_100007.csv**--This is footer.

I need to replace the footer with

in unix. Please help. Thanks

Answer Source
sed -i.bak '$s/WOR/VWOR/g' file

should do it.


  • Here $ picks the last line.
  • s/WOR/VWOR/g does the global substitution.
  • -i stands for inplace edit which means directly modify the file. A backup with .bak will be auto-created.


If your shell doesn't support inplace edit do

sed '$s/WOR/VWOR/g' file >tempfile && mv tempfile file
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download