bash - Spread 'sed' command over multiple lines -
i trying spread 1 sed command on several lines in bash file. have multiple patterns sed checks , hoping separate of patterns line change. here current script not work, putting on 1 line works hoping clean bit , split things up.
#!/bin/sh -f #files=$(ls -1 | egrep '.avi|.mkv'); #echo $files f in *.mkv *.avi; renf=`echo $f | tr '.' ' ' | sed -e 's/ \([^ ]*\)$/.\1/; s/\ \[sharethefiles\ com\]//i' \ -e 's/\ x264\-ctu//i; s/\ x264\-bia//i; s/\ x264\-fov//i' \ -e 's/\ xvid\-lol//i; s/\ xvid\-xor//i; s/\ xvid\-notv//i; s/\ xvid\-fqm//i; s/\ xvid\-p0w4//i; xvid\-bia//i; s/\ xvid\-chgrp//i; s/\ xvid\-fov//i' \ -e 's/\ pdtv\-fov//i; s/\ pdtv\-river//i; s/\ pdtv\-sfm' \ -e 's/\ dts\-chd//i; s/\ web\-dl//i; s/\ h264\-surfer//i' \ -e 's/\ dsr//; s/\ ws//i; s/\ pdtv//i; s/\ x264//i; s/\ blu\-ray//; s/\ bdrip//i; s/\ bluray//i; s/\ hdtv//i; s/\ dts//i; s/\ ac3//i; s/\ dd5//i; s/\ dualaudio//i; s/\ aac2//i; s/\ xvid//i'` #echo $renf if [ "$f" == "$renf" ]; echo "filename cleaned." else mv "$f" "$renf" fi done
thanks help!
the problem on line:
-e 's/\ xvid\-lol//i; s/\ xvid\-xor//i; s/\ xvid\-notv//i; s/\ xvid\-fqm//i; s/\ xvid\-p0w4//i; xvid\-bia//i; s/\ xvid\-chgrp//i; s/\ xvid\-fov//i' \
there's missing s/
. should be:
-e 's/\ xvid\-lol//i; s/\ xvid\-xor//i; s/\ xvid\-notv//i; s/\ xvid\-fqm//i; s/\ xvid\-p0w4//i; s/\ xvid\-bia//i; s/\ xvid\-chgrp//i; s/\ xvid\-fov//i' \
i included backslash consistency.
this line missing //i
:
-e 's/\ pdtv\-fov//i; s/\ pdtv\-river//i; s/\ pdtv\-sfm
corrected:
-e 's/\ pdtv\-fov//i; s/\ pdtv\-river//i; s/\ pdtv\-sfm//i
the error messages got led me source of errors:
sed: -e expression #3, char 93: unknown command: `x'
and
sed: -e expression #4, char 51: unterminated `s' command
here's suggestion on how make more readable , maintainable:
while read -r pattern sedscript+="$pattern;" done <<eof s/ \([^ ]*\)$/.\1/ s/\ \[sharethefiles\ com\]//i s/\ x264\-ctu//i s/\ x264\-bia//i ... s/\ xvid//i eof renf=$(echo $f | tr '.' ' ' | sed -e "$sedscript")
Comments
Post a Comment