Clarification of 'sed' usage -
i blindly followed command tutorial rename several folders @ time. can explain meaning of "p;s" given argument sed's -e option.
[root@linuxd delsure]# ls ar1 ar2 ar3 ar4 ar5 ar6 ar7 [root@linuxd delsure]# find . -type d -name "ar*"|sed -e "p;s/ar/ar/g"|xargs -n2 mv [root@linuxd delsure]# ls ar1 ar2 ar3 ar4 ar5 ar6 ar7
a sed
script (the bit next -e
option) can contain multiple commands, separated ;
the script in illustration uses p
command print pattern space (i.e. line read input) followed s
command perform substitution on pattern space.
by default (unless pattern space cleared or -n
alternative given sed) after processing each line current pattern spaceline printed again, result of substitution printed.
another way write same thing be:
sed -e "p" -e "s/ar/ar/g"
this separates commands 2 scripts. way be:
sed "p;s/ar/ar/g"
because if argument sed script -e
alternative not needed
sed
No comments:
Post a Comment