Skip to main content
edited tags
Link
Gilles 'SO- stop being evil'
  • 866.5k
  • 205
  • 1.8k
  • 2.3k
Source Link

Using multiple sed commands for text manipulation

I have a bash file, in which I would like to make several changes.

sed -i 's/      /    /g' testfile
sed -i -e 's/#[a-z]$//' -e '/^$/d' testfile
sed -i 's/ *$//' testfile
sed '/##=/ r header' testfile

In first command would like to replace TAB with spaces and after that remove comments(there are also comments, which begin with ##) and empty lines. After that would like to insert a file after a specified pattern in my file. Is there something wrong with command ordering?