LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 06-17-2004, 05:54 AM   #1
existent
LQ Newbie
 
Registered: Jun 2004
Posts: 2

Rep: Reputation: 0
script #!/bin/bash, problem with space in file names


HEllo,

I have the script like bellow, but I have a problem when the file in directory "~tmp/" has name with white space, for instance "big and boss.htm". then $i equal just firs part of the file name fo instance "big" and not whole name. thats the problem,
do you know how to do it "correct"?




----------------------------------------
#!/bin/bash
cd /home/tmp
for i in `find . -type f`



do

.....

done
------------------------------------------

THANKS O LOT!!!!
Tom_ex
 
Old 06-17-2004, 06:25 AM   #2
mikshaw
LQ Addict
 
Registered: Dec 2003
Location: Maine, USA
Distribution: Slackware/SuSE/DSL
Posts: 1,320

Rep: Reputation: 45
Try putting your variable in quotes: "$i"
 
Old 06-17-2004, 07:03 AM   #3
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
maybe a backslash? (as bash interprits them as "dont interprit tht
charactor"

like:

/tmp/this\ is\ a\ file\ that\ has\ may\ bad\ chars\(\)\(\)\[\]\;\|\ .com

(note: the ".com" indicates the file is a windows virus, so dont click it)
 
Old 06-17-2004, 08:13 AM   #4
existent
LQ Newbie
 
Registered: Jun 2004
Posts: 2

Original Poster
Rep: Reputation: 0
Yep thats good advises, thanks. But that resolved my problem only 50%.
because problem was with IFC. I set it on IFS=$'\n' and now it works.
Anyway thans for your advises.

Tom_ex
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with Fat long file names in Bash brett90 Slackware 5 06-03-2005 12:15 PM
bash:output file names from shell script to vi sickboy Linux - Newbie 6 10-14-2004 03:40 AM
bash script, line1 #!/bin/sh - what does it mean? ombill Linux - Newbie 5 07-05-2004 11:38 AM
Bash crashes ? File names with () and spaces Danodare Slackware 1 02-27-2004 02:50 PM
bin/bash:usr/bin/lpr NO SUCH FILE OR DIRECTORY Adibe_Hamm Linux - Newbie 3 10-14-2003 02:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:28 AM.

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