LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   shell script error (sed) (https://www.linuxquestions.org/questions/linux-newbie-8/shell-script-error-sed-790590/)

MartenH 02-21-2010 01:30 PM

shell script error (sed)
 
I am trying to replace some bad characters in a filename but have trouble getting it to work.

I currently have
Code:

for file in /somefolder/*
do
mv "$file" $(echo "$file" | sed 's/\xE4/ä/g')
done

This causes missing operand after filename. So I cut it down to find the problem.
Code:

for file in /somefolder/*
do
echo "$file" | sed 's/\xE4/ä/g'
done

Now I get
Code:

sed: -e expression #1, char 10: unterminated `s' command
Everything works fine if I trigger the same sed statement manually in the folder
Code:

ls | sed 's/\xE4/ä/g'

MartenH 02-21-2010 02:17 PM

Solution found as an extra program!
Code:

$urpmi convmv
$convmv --notest -r - f ISO_8859-1 -t UTF-8 somefolder/*

-r makes it recursive
--notest makes it do it for real. Skip this to do a trial run


All times are GMT -5. The time now is 03:28 AM.