Using multiple sed commands
Hi I'm looking to search through a file and output the values of a line that matches the following regex with the matching text removed, I don't need it output to a file. This is what I am currently using and it is outputting the required text but multiple times: #!/bin/sh for file in *; do sed -e 's/^owner //g;p;!d ; s/^admin //g;p;!d ; s/^loc //g;p;!d ; s/^ser //g;p;!d' $file done The preferred format would be something like this so I could have control over what happens inbetween: for file in *; do sed 's/^owner //g;p' $file | head -1 sed 's/^admin //g;p' $file | head -1 sed '/^loc //g;p'