Re: How do I get a list of filenames with spaces on bash?
- From: Ed Morton <morton@xxxxxxxxxxxxxx>
- Date: Thu, 24 Jan 2008 09:00:27 -0600
On 1/24/2008 7:49 AM, Chad wrote:
On Jan 23, 11:17 pm, jellybean stonerfish <stonerf...@xxxxxxxxxxxxx>
wrote:
On Wed, 23 Jan 2008 20:42:46 -0800, Chad wrote:
A long time ago, some Professor used some kind of 'echo' combination on
Unix to get a list of filename with space. I no longer have a copy of
the script.
I was tried something like the following
[cdalten@localhost ~]$ echo */
In bash you could use
[cdalten@localhost ~]$ ls *\ *
Note that is a \ not a /
The \ makes the shell treat the following space like a regular
character, not a word separator.
If you prefer to use echo
[cdalten@localhost ~]$ echo *\ *
Would also work, but the filenames would all come
out on one line, making them hard to read.
What do you want to do, just list filenames with spaces, or do something
to the filenames with spaces?
I was trying to rename all the filenames with spaces in them.
Assuming you want to replace single blank chars with underscores:
for f in *\ *
do
n="${f// /_}"
[ ! -f "$n" ] &&
cp -- "$f" "$n" &&
rm -- "$f"
done
If your file names can have multiple spaces or tabs or... you may need a
modified solution.
Regards,
Ed.
.
- Follow-Ups:
- Re: How do I get a list of filenames with spaces on bash?
- From: Stephane Chazelas
- Re: How do I get a list of filenames with spaces on bash?
- References:
- Re: How do I get a list of filenames with spaces on bash?
- From: jellybean stonerfish
- Re: How do I get a list of filenames with spaces on bash?
- From: Chad
- Re: How do I get a list of filenames with spaces on bash?
- Prev by Date: Re: Strange awk substr bug
- Next by Date: Re: command substitution error using bash
- Previous by thread: Re: How do I get a list of filenames with spaces on bash?
- Next by thread: Re: How do I get a list of filenames with spaces on bash?
- Index(es):
Relevant Pages
|