Linux Newbie help
 help / color / mirror / Atom feed
* File names with spaces
@ 2003-02-17 19:11 Theo. Sean Schulze
  2003-02-17 20:34 ` Brian Jackson
  0 siblings, 1 reply; 21+ messages in thread
From: Theo. Sean Schulze @ 2003-02-17 19:11 UTC (permalink / raw)
  To: linux-newbie

Hello,

I am trying to write a bash shell script that will translate spaces in file names into underline characters.  This is the script as I have it now:


for file in `ls`
do
	echo $file
	newfile=`ls ${file} | tr '[:space:]' '[_*]'`
	echo File is named ${file}
	echo The new file is named ${newfile}
	# [[ -s $newfile ]] || (mv $file $newfile)
	sleep 2
done

The lines that begin with echo and the sleep line are for debugging.  What they have shown me is that the $file is getting set to the first word in the file name on the first iteration, the second word on the second interation, etc.  (The file names look like "001 of 150 files", "002 of 150 files", etc.)  So, on the first iteration, $file is egual to "001", on the second iteration $file is equal to "of", etc.  Yet, if I go to the directory and issue `ls`, the filenames are shown as one would expect with the whole four word filename on one line.

Can anyone give me a hint on how to fix this so that the whole filename is loaded into $file?

TIA,
Sean

-- 
Theo. Sean Schulze
tschulze@teamfinders.org
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2003-02-23 15:25 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-17 19:11 File names with spaces Theo. Sean Schulze
2003-02-17 20:34 ` Brian Jackson
2003-02-18 21:37   ` Theo. Sean Schulze
2003-02-20 10:22     ` J.
2003-02-20 17:13       ` [SOLVED] " Theo. Sean Schulze
2003-02-20 19:43         ` J.
2003-02-21  8:59         ` J.
2003-02-23 13:30           ` Theo. Sean Schulze
2003-02-23 14:12             ` Problem installing avi libraries Peter Howell
2003-02-23 15:25               ` Ray Olszewski
2003-02-23 14:46             ` [SOLVED] Re: File names with spaces J.
2003-02-21  7:29       ` file transfer via telnet ichi
2003-02-20 20:10         ` Nathan
2003-02-20 21:44           ` Eckhardt, Rodolpho H. O.
2003-02-21  8:27             ` Jos Lemmerling
2003-02-21  8:51         ` J.
2003-02-21 18:55         ` whitnl73
2003-02-22  9:55           ` Thiago F.G. Albuquerque
2003-02-22 10:16             ` J.
2003-02-22 15:59             ` whitnl73
2003-02-22 16:03           ` whitnl73

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox