[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Spaces in File name Handling
From: |
alupu |
Subject: |
Spaces in File name Handling |
Date: |
Mon, 08 Mar 2004 23:53:04 +0000 |
File/directory names containing space(s).
Linux 2.6.3, Bash 2.05b.0
Question: How do you handle this in batch files?
Examples (typical):
Assume a directory with two files(or subdirectories), 'A' and 'B C'
Three bash shell procedures, 1, 2 and 3:
#!/bin/sh
#1. This works:
TEMP1="B C"
TEMP2=A
for i in "$TEMP" "$TEMP1" ; do ls -ld "$i" ; done
#2. This also works:
for i in "B C" "A" ; do ls -ld "$i" ; done
#3. However, the real case, doesn't work ...
TMP=`ls -AQ`
for i in "$TMP" ; do ls -ld "$i" ; done
# ... (in any variations, $TMP, $i, etc.) ...
# ... although the output of this line,
echo $TMP
# is (as you'd expect):
A B C
Thank you for your help,
-- Alex
- Spaces in File name Handling,
alupu <=