LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 04-21-2003, 07:01 PM   #1
Crashed_Again
Senior Member
 
Registered: Dec 2002
Location: Atlantic City, NJ
Distribution: Ubuntu & Arch
Posts: 3,503

Rep: Reputation: 57
Dealing with spaces in a shell


Oh boy I forgot how to do this. Say you have a file called:

this is the file.txt

and you want to rename it to:

file.txt

I forgot how to indicate the spaces in the filename. If you just do:

mv this is the file.txt file.txt

it obviously thinks your trying to move multiple files.

How do you indicate the space? I'm losing brain cells fast...
 
Old 04-21-2003, 07:08 PM   #2
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix, 98,2000 + various
Posts: 3,171

Rep: Reputation: 52
mv "file .txt" file.txt
 
Old 04-21-2003, 07:13 PM   #3
Crashed_Again
Senior Member
 
Registered: Dec 2002
Location: Atlantic City, NJ
Distribution: Ubuntu & Arch
Posts: 3,503

Original Poster
Rep: Reputation: 57
Ah yes of course. You just put it in parenthesis marks. Thanks!
 
Old 04-21-2003, 09:33 PM   #4
wapcaplet
Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
I don't know if it depends on what shell you're using, but with bash you can escape the spaces with a backslash:

mv Some\ file\ with\ spaces.txt Some_file_without_spaces.txt

(get rid of those wherever possible, they are a pain )
 
Old 04-21-2003, 10:13 PM   #5
Crashed_Again
Senior Member
 
Registered: Dec 2002
Location: Atlantic City, NJ
Distribution: Ubuntu & Arch
Posts: 3,503

Original Poster
Rep: Reputation: 57
Quote:
Originally posted by wapcaplet
(get rid of those wherever possible, they are a pain )
Tell me about it. Thanks.
 
Old 04-21-2003, 11:30 PM   #6
serz
Member
 
Registered: Apr 2003
Location: Buenos Aires, Argentina
Distribution: Slackware, Gentoo
Posts: 397

Rep: Reputation: 30
It's easy.
If you would like to add spaces to this: I_want_spaces it would be:
I\ want\ spaces

I think that's ok.
 
  


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 Scripting and Files With Spaces Matir Programming 12 08-17-2005 02:43 AM
Dealing with partitions. lvella Linux - General 4 07-22-2005 09:37 AM
Dealing with an app lockup in X Comreak Linux - Software 7 06-05-2005 10:07 AM
Dealing with spaces in filenames(ksh) SeT Programming 6 11-20-2004 04:04 AM
Remove white spaces in HTML files using shell : Possible???????? cpanelskindepot Programming 2 08-06-2004 12:14 AM


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