LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-08-2007, 08:56 PM   #1
trscookie
Member
 
Registered: Apr 2004
Location: oxford
Distribution: gentoo
Posts: 463

Rep: Reputation: 30
stupid shell moans about spaces....


can someone please amend this code so it would work, I have tried everything :'(

Code:
for i in *; do mv $i `echo "$i" | tr '[A-Z]' '[a-z]'`; done
mv: target `funnier.jpg' is not a directory
mv: `original.jpg' and `original.jpg' are the same file

thanks, trscookie
 
Old 08-08-2007, 09:07 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
I haven't tested it but have you tried wrapping your first $i in double quotes - e.g. "$i"? Also, have a look here at http://www.linuxquestions.org/questi....php?p=2810545 for a similar question.
 
Old 08-08-2007, 10:09 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
The shell is not stupid.....it's not smart enough to be stupid. Your example doesn't show it, but the title implies that you have some file names with spaces (bad).

If you have a file name with a space, see what happens when to just try to rename that one file---eg:
mv this file newname
vs
mv "this file" newname
 
Old 08-08-2007, 10:11 PM   #4
trscookie
Member
 
Registered: Apr 2004
Location: oxford
Distribution: gentoo
Posts: 463

Original Poster
Rep: Reputation: 30
Ok how about this:


how do I return what the name of the current folder I'm in?

for example:

if you run pwd it returns the full path I just want to return the last folder that I entered?

Cheers again.
 
Old 08-08-2007, 10:33 PM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
pwd | sed 's,^.*/,,'

(I'm sure there's some other way, too....)
 
Old 08-08-2007, 10:38 PM   #6
trscookie
Member
 
Registered: Apr 2004
Location: oxford
Distribution: gentoo
Posts: 463

Original Poster
Rep: Reputation: 30
thanks, I could never get to grips with sed
 
Old 08-09-2007, 08:04 AM   #7
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by trscookie
thanks, I could never get to grips with sed
http://www.grymoire.com/Unix/Sed.html#uh-8
Best tutorial I have seen to date.....
 
Old 08-09-2007, 08:52 AM   #8
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 66
Code:
/bin/ls -1 *[A-Z]* | while read i; do mv "$i" "$(tr '[A-Z]' '[a-z]' <<<"$i")"; done
or recursive:
Code:
find . -depth -name '*[A-Z]*' -print | while read i; do mv "$i" "$(tr '[A-Z]' '[a-z]' <<<"$i")"; done
Yves.
 
Old 08-09-2007, 08:54 AM   #9
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 66
Quote:
Originally Posted by trscookie
how do I return what the name of the current folder I'm in? [...] I just want to return the last folder that I entered?
Code:
basename "$PWD"
Yves.
 
  


Reply



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
KDE: How do I switch between desktop spaces? Am I stupid :| Xel'naga666 Linux - Desktop 10 05-04-2010 01:29 AM
shell programming - removing files with spaces ANU Programming 4 08-08-2006 04:42 AM
Shell Scripting and Files With Spaces Matir Programming 12 08-17-2005 01:43 AM
the BSA and piracy moans!!! bigjohn General 0 06-04-2003 03:32 PM
Dealing with spaces in a shell Crashed_Again Linux - Newbie 5 04-21-2003 10:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:47 PM.

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
Open Source Consulting | Domain Registration