Linux Newbie help
 help / color / mirror / Atom feed
From: "Theo. Sean Schulze" <tschulze@teamfinders.org>
To: linux-newbie <linux-newbie@vger.kernel.org>
Subject: Re: File names with spaces
Date: Tue, 18 Feb 2003 22:37:21 +0100	[thread overview]
Message-ID: <20030218213721.GA11729@teamfinders.org> (raw)
In-Reply-To: <200302171434.16323.brian@mdrx.com>

Thanks, that did help, although it didn't solve the problem.  I now recognize that the problem is in assigning the variable.  Both my version with ls and the version with find in the example give the expected results when printing to the console, but they both fail when used to assign a string including spaces to a variable.

I need to find a way to maintain the integrity of the string as I assign it to the file variable.  I tried `echo (ls -1)` and `echo "(ls -1)"`, but neither works.  Changing the parentheses to brackets doesn't help either.

Cheers,
Sean

On Mon, Feb 17, 2003 at 02:34:16PM -0600, Brian Jackson hunted and pecked out:
> You can try to adapt this example from The Advanced Bash Scripting Guide:
> http://www.tldp.org/LDP/abs/html/moreadv.html#EX57
> 
> It deletes the file, but it shouldn't be too hard to adapt to your needs.
> 
> --Brian
> 
> On Monday 17 February 2003 01:11 pm, Theo. Sean Schulze wrote:
> > 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

  reply	other threads:[~2003-02-18 21:37 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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
  -- strict thread matches above, loose matches on Subject: below --
2003-02-18  9:36 File names with spaces robin
2003-02-18 13:59 ` Jim Reimer
2003-02-28 23:46 ` Mike Castle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030218213721.GA11729@teamfinders.org \
    --to=tschulze@teamfinders.org \
    --cc=linux-newbie@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox