Re: Spaces in file names
- From: floyd@xxxxxxxxxx (Floyd L. Davidson)
- Date: Mon, 31 Dec 2007 03:31:16 -0900
"Leslie Rhorer" <lrhorer@xxxxxxxxxxx> wrote:
Hey, that works! Thanks.
But it would be a lot easier to just do this:
#!/bin/bash
for file in * ; do
echo "$file"
done
exit 0
The trick is putting quotes around $file. Using `ls -1 *`
is unnecessary, and so is find.
"Dan Mills" <dmills@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:477856c3$0$21094$da0feed9@xxxxxxxxxxxxxxxxx
On Sun, 30 Dec 2007 19:31:45 -0600, Leslie Rhorer wrote:
OK, here's the problem. I need to automatically manipulate the file
names
of a number of files whose filenames have spaces in them.
for file in `ls -1 *`
do
<do stuff>
done
How about something like (untested):
#!/bin/bash
IFS=$'\n'
#IFS is the internal field separator in bash and
#here we set it to be new line only.
for file in $(find . -type f)
do
<stuff with "$file">
done
HTH.
Regards, Dan.
--
Floyd L. Davidson <http://www.apaflo.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) floyd@xxxxxxxxxx
.
- Follow-Ups:
- References:
- Spaces in file names
- From: Leslie Rhorer
- Re: Spaces in file names
- From: Dan Mills
- Re: Spaces in file names
- From: Leslie Rhorer
- Spaces in file names
- Prev by Date: Re: Spaces in file names
- Next by Date: Re: Spaces in file names - watch for arg list too long with ls *
- Previous by thread: Re: Spaces in file names
- Next by thread: Re: Spaces in file names - watch for arg list too long with ls *
- Index(es):
Relevant Pages
|