I have a bash file, in which I would like to make several changes.sed -i 's/      /    /g' testfilesed -i -e 's/#[a-z]$//' -e '/^$/d' testfilesed -i 's/ *$//' testfilesed '/##=/ r header' testfileIn 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?
Using multiple sed commands for text manipulation
shell script;text processing;sed
you can give multiple instruction in one shot of sed, for example:sed 's/\t/    /g;/^ *$/d;s/^#/NODIESE/' testfilethis single line replace tab with spacedelete line that start with empty stuff (or empty line)replace Dash at start with the word NODIESEso your test file is processed only once and you launch sed only one time. 