Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux 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.


  Search this Thread
Old 05-27-2005, 09:53 AM   #1
Registered: Oct 2001
Location: Fort Collins, Colorado
Distribution: RHEL3/FedoraCore3
Posts: 61

Rep: Reputation: 15
replacing single quotes in file names

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 :-)
Old 05-27-2005, 10:02 AM   #2
LQ Guru
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 261Reputation: 261Reputation: 261
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)
Old 05-27-2005, 11:29 AM   #3
Senior Member
Registered: Dec 2003
Location: Brasil
Distribution: Arch
Posts: 1,037

Rep: Reputation: 46
Re: replacing single quotes in file names

hi there,

Originally posted by adenardo

for i in *.jpg; do mv "$i" `echo $i | sed "s/'//g"`; done
did you try sed???


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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with quotes and double quotes Andruha Slackware 6 01-02-2010 04:44 PM
Single IP multible domain names tangle Linux - Networking 4 11-25-2005 12:17 AM
Using single quotes vs double quotes in PHP strings vharishankar Programming 6 07-11-2005 11:41 AM
Replacing a particular position in a file sgracelin Linux - Newbie 1 06-20-2005 05:54 PM
In BASH shell, what is the difference in usage between single and double quotes? davidas Linux - Newbie 2 04-05-2004 03:00 AM > Forums > Linux Forums > Linux - General

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

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