combine two sed commands [duplicate]
You can do:
for each in *; do sed -i.bak 's/^"//g; 1d' "$each"; done
You can put them into the same invocation of sed like this:
for f in *; do sed -i '1d;s/^"//' "$f"; done
As well as combining the two sed commands, I have also used a glob *
rather than attempting to parse ls, which is never a good idea.
Also, your substitution needn't be global, as it can by definition only apply to each line once, so I removed the g
modifier as well.
You can do it with a single commmand in this way:
sed -i.bak --separate '1d ; s/^"//' *
Explanation
With --separate
you're telling sed to treat the files separately, the default is to process them as a long single file but you are using adresses (1
in the first command) so the default doesn't work.
'1d ; s/^"//'
just combines the two commands (separated by ;
).