LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-21-2010, 01:30 PM   #1
MartenH
Member
 
Registered: Jul 2005
Location: Lund, Sweden
Distribution: Mandriva
Posts: 76

Rep: Reputation: 23
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'
 
Old 02-21-2010, 02:17 PM   #2
MartenH
Member
 
Registered: Jul 2005
Location: Lund, Sweden
Distribution: Mandriva
Posts: 76

Original Poster
Rep: Reputation: 23
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script, sed nushki Linux - Newbie 1 03-31-2009 01:36 PM
Shell Script , using Sed mogra Linux - Newbie 8 05-07-2008 01:18 PM
Using sed in a shell script RobHill Linux - General 4 05-29-2007 03:31 PM
Sed shell script question pete1234 Programming 4 08-18-2006 09:15 PM
shell script problem on sed. chooi Programming 3 02-10-2006 11:35 PM


All times are GMT -5. The time now is 07:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration