How to replace the first line using sed?

24,013

You can use -i flag to sed which will edit in-place and also take backup:

sed -i.bak "1 s/.*/$new_header/" inputfile

Note that the -i option is non-standard and may work differently in different implementations of sed. See How can I achieve portability with sed -i (in-place editing)?

Share:
24,013

Related videos on Youtube

William R
Author by

William R

Updated on September 18, 2022

Comments