LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux > Linux - General
User Name
Password
Linux - General This forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Thread Tools
Old 05-27-2005, 10:53 AM   #1
adenardo
Member
 
Registered: Oct 2001
Location: Fort Collins, Colorado
Distribution: RHEL3/FedoraCore3
Posts: 61
Thanked: 0
replacing single quotes in file names


[Log in to get rid of this advertisement]
I have a bunch of photos called things like:

ben's birthday.jpg
ben's first day skiing.jpg
haille's dog.jpg

I want to automate the removal of the single quotes, changing their names to:

bens birthday.jpg
bens first day skiing.jpg
hailles dog.jpg

I have used :

for i in *.jpg; do mv "$i" `echo $i | tr ' ' '_'`; done

to replace spaces in filenames with underscores. I have been unable to modify this to work for single quotes. any help appreciated :-)
adenardo is offline     Reply With Quote
Old 05-27-2005, 11:02 AM   #2
trickykid
Guru
 
Registered: Jan 2001
Posts: 23,977
Thanked: 8
Reading the man page for tr, doesn't seem to have a specific option for the back tick.. '

You might have to provide it with the octal number.. from the man page:

\NNN character with octal value NNN (1 to 3 octal digits)
trickykid is offline     Reply With Quote
Old 05-27-2005, 12:29 PM   #3
slackie1000
Senior Member
 
Registered: Dec 2003
Location: Brasil
Distribution: Arch
Posts: 1,036
Thanked: 0
Re: replacing single quotes in file names

hi there,

Quote:
Originally posted by adenardo

for i in *.jpg; do mv "$i" `echo $i | sed "s/'//g"`; done
did you try sed???
regards
slackie1000
slackie1000 is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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
Single IP multible domain names tangle Linux - Networking 4 11-25-2005 01:17 AM
Using single quotes vs double quotes in PHP strings hs123 Programming 6 07-11-2005 12:41 PM
Replacing a particular position in a file sgracelin Linux - Newbie 1 06-20-2005 06:54 PM
Problems with quotes and double quotes Andruha Slackware 4 02-15-2005 10:44 AM
In BASH shell, what is the difference in usage between single and double quotes? davidas Linux - Newbie 2 04-05-2004 04:00 AM


All times are GMT -5. The time now is 02:37 AM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration