From: Brian Jackson <brian@mdrx.com>
To: "Theo. Sean Schulze" <tschulze@teamfinders.org>,
linux-newbie <linux-newbie@vger.kernel.org>
Subject: Re: File names with spaces
Date: Mon, 17 Feb 2003 14:34:16 -0600 [thread overview]
Message-ID: <200302171434.16323.brian@mdrx.com> (raw)
In-Reply-To: <20030217191140.GA13495@teamfinders.org>
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
-
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
next prev parent reply other threads:[~2003-02-17 20:34 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 [this message]
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
-- 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=200302171434.16323.brian@mdrx.com \
--to=brian@mdrx.com \
--cc=linux-newbie@vger.kernel.org \
--cc=tschulze@teamfinders.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