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 09-10-2009, 12:43 PM   #16
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,697

Original Poster
Rep: Reputation: 48

when i typed n to that line, it said Missing }.

that echo $0 prompted me for the same responses. when i typed n, it said -tcsh
 
Old 09-10-2009, 12:44 PM   #17
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,697

Original Poster
Rep: Reputation: 48
find . -name '* *'.[jJ][pP][gG] | while read file; do echo mv "$file" "${file// /}"; done


that what was i tried to run, FYI
 
Old 09-10-2009, 12:52 PM   #18
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,074

Rep: Reputation: 387Reputation: 387Reputation: 387Reputation: 387
Right, that's what I feared, csh variants are completely different animals. Unfortunately I am not proficient with csh, and I am really no interested in learning it. I suggest you to install bash and run my command in bash. None of the snippets posted in this thread (by me and the others) will work in any csh variant, I think.
 
Old 09-10-2009, 12:52 PM   #19
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,697

Original Poster
Rep: Reputation: 48
Could it be that i have bash but i'm just not in it? how could i tell or try switching over to it?
 
Old 09-10-2009, 12:54 PM   #20
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,697

Original Poster
Rep: Reputation: 48
or should i do a su - and try it maybe?
 
Old 09-10-2009, 12:55 PM   #21
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,074

Rep: Reputation: 387Reputation: 387Reputation: 387Reputation: 387
If you have it installed just running it should work

Code:
bash
Then echo $0 should report "bash" instead of "tcsh". And my command should work inside that new shell. To go back to tcsh you can type "exit". By the way, did you install tcsh voluntarily or did it come by default in your distribution? Most distros nowadays ship either bash as the default shell (and maybe busybox's ash for init, which is lighter).
 
Old 09-10-2009, 12:56 PM   #22
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,074

Rep: Reputation: 387Reputation: 387Reputation: 387Reputation: 387
Quote:
Originally Posted by rjo98 View Post
or should i do a su - and try it maybe?
No, never run massive commands like this as root. You shouldn't operate as root. Only for administrative tasks.
 
Old 09-10-2009, 01:00 PM   #23
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,697

Original Poster
Rep: Reputation: 48
OK, I typed bash then echo $0 and it told me bash!!!

so now i ran the command and a TON of stuff flew by on the screen, the last line being

mv ./06-13-2009/gus/gus new9.jpg ./06-13-2009/gus/gusnew9.jpg


so i guess I should be good to remove the echo right?
 
Old 09-10-2009, 01:02 PM   #24
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,074

Rep: Reputation: 387Reputation: 387Reputation: 387Reputation: 387
So it seems. If you want to be really safe, you could backup the whole directory before running it.
 
Old 09-10-2009, 01:04 PM   #25
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,697

Original Poster
Rep: Reputation: 48
would this be a tar.gz i would be making?

does it show i'm very new to Linux :-)
 
Old 09-10-2009, 01:07 PM   #26
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,074

Rep: Reputation: 387Reputation: 387Reputation: 387Reputation: 387
Quote:
Originally Posted by rjo98 View Post
would this be a tar.gz i would be making?
Whatever suits you, you can use tar or even cp. For example:

Code:
tar cf backup.tar orig_dir/
# or
cp -R orig_dir/ dist_dir
I didn't enable compression because most images surely will already be compressed, so you are going to gain very little from compression and it will take much longer to do the backup if the directory is big. Once you have checked that the renaming went ok you can delete the backup.

Quote:
does it show i'm very new to Linux :-)
We all were at some point
 
Old 09-10-2009, 01:25 PM   #27
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,697

Original Poster
Rep: Reputation: 48
Thanks for all the help man. hopefully i can take it from here, hopefully :-)
 
Old 09-10-2009, 01:50 PM   #28
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,697

Original Poster
Rep: Reputation: 48
Found a small problem. I get a "no such file or directory" error when it tries to remove the spaces from folder names. is there a way to make it do only the files and not folder names as well?
 
Old 09-10-2009, 01:57 PM   #29
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,074

Rep: Reputation: 387Reputation: 387Reputation: 387Reputation: 387
Using -type f should solve that, in the find part. I changed the examples above (well, in the previous page by now) to reflect that.
 
Old 09-10-2009, 02:00 PM   #30
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,697

Original Poster
Rep: Reputation: 48
ok, so it should have -type f in between the . and the -name, as shown below. i'll give it a shot

find . -type f -name '* *'.[jJ][pP][gG] | while read file; do echo mv "$file" "${file// /}"; done
 
  


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
remove xtra spaces lipun4u Linux - Newbie 2 09-16-2008 02:56 AM
remove all spaces from a line in C xeon123 Programming 12 10-23-2007 02:29 AM
How to remove spaces from a string pawan_songara Programming 14 08-30-2006 10:20 PM
how to find the spaces on the folder??? ashley75 Linux - General 4 04-10-2006 04:56 PM
Is it possible to remove spaces Alex_jacobson Linux - General 4 01-16-2005 11:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10: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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration