From: Janis Papanagnou on
Thomas 'PointedEars' Lahn wrote:
> Janis Papanagnou wrote:
>
>> Thomas 'PointedEars' Lahn wrote:
>>> moonhkt wrote:
>>>> pk wrote:
>>>>> Thomas 'PointedEars' Lahn wrote:
>>>>>>> #!/bin/ksh
>>>>>>> MDIR=/phx/migration
>>>>>>> for i in $MDIR/load $MDIR/src
>>>>>> Can be compacted to
>>>>>>
>>>>>> for i in $MDIR/{load,src}
>>>>>>
>>>>>> But you really don't want to use `for' here (consider $IFS in
>>>>>> filenames).
>>>>> If what you're saying was true, then
>>>>>
>>>>> for i in *
>>>>>
>>>>> will never work when filenames have $IFS in them.
>>> The point is that $MDIR/{load,src} may contain $IFS.
>> The point is that you should quote it
>>
>> "$MDIR"/{load,src}
>>
>> The 'for' construct has no problem with that.
>
> The quoted parameter does not expand equally in every case. For example,
> with
>
> MDIR='/windows/c/Documents and Settings/PointedEars'
>
> (and a corresponding file existing) the `for' parameter
>
> "$MDIR"/Pointed*
>
> expands to
>
> '/windows/c/Documents and Settings/Pointed*'
>
> while
>
> $MDIR/Pointed*
>
> expands to
>
> /windows/c/Documents and Settings/PointedEars
>
> (only that space is in $IFS so this is not feasible either.) Your
> suggestion
>
> "$MDIR"/{load,src}
>
> only "works" because pathname expansion is _not_ performed there, only
> parameter and brace expansion.

You're writing nonsense.

>
>>>> [...]
>>>> MDIR=/phx
>>>> for i in $MDIR/{load,utility,src}
>>>> do
>>>> cd $i
>>>> find $i ! -type d -print
>>>> done
>> If load, utility, and src are in the same directory this won't work,
>> because in the first iteration you change directory to 'load' and then
>> try to continue _from there_ to 'utility', and finally to 'src'.
>>
>> But you can perform the commands in a subshell
>> [...]
>> And you should check whether the cd succeeded before continuing.
>> [...]
>> But why, in the first place, do you perform the cd if you're providing
>> the absolute path to find anyway?
>
> Why, in the first place, are they using `for' here and not
>
>> [...]
>>> find $MDIR/{load,utility,src} ! -type d
>> [...]
>
> ?
>
>
> PointedEars
From: Thomas 'PointedEars' Lahn on
Janis Papanagnou wrote:

> Thomas 'PointedEars' Lahn wrote:
>> Janis Papanagnou wrote:
>>> Thomas 'PointedEars' Lahn wrote:
>>>> moonhkt wrote:
>>>>> pk wrote:
>>>>>> Thomas 'PointedEars' Lahn wrote:
>>>>>>>> #!/bin/ksh
>>>>>>>> MDIR=/phx/migration
>>>>>>>> for i in $MDIR/load $MDIR/src
>>>>>>> Can be compacted to
>>>>>>>
>>>>>>> for i in $MDIR/{load,src}
>>>>>>>
>>>>>>> But you really don't want to use `for' here (consider $IFS in
>>>>>>> filenames).
>>>>>> If what you're saying was true, then
>>>>>>
>>>>>> for i in *
>>>>>>
>>>>>> will never work when filenames have $IFS in them.
>>>> The point is that $MDIR/{load,src} may contain $IFS.
>>> The point is that you should quote it
>>>
>>> "$MDIR"/{load,src}
>>>
>>> The 'for' construct has no problem with that.
>>
>> The quoted parameter does not expand equally in every case. For
>> example, with
>>
>> MDIR='/windows/c/Documents and Settings/PointedEars'

MDIR='/windows/c/Documents and Settings/'

>> (and a corresponding file

/windows/c/Documents and Settings/PointedEars

>> existing) the `for' parameter
>>
>> "$MDIR"/Pointed*
>>
>> expands to
>>
>> '/windows/c/Documents and Settings/Pointed*'
>>
>> while
>>
>> $MDIR/Pointed*
>>
>> expands to
>>
>> /windows/c/Documents and Settings/PointedEars
>>
>> (only that space is in $IFS so this is not feasible either.) Your
>> suggestion
>>
>> "$MDIR"/{load,src}
>>
>> only "works" because pathname expansion is _not_ performed there, only
>> parameter and brace expansion.
>
> You're writing nonsense.

I had corrected myself as to the value of $MDIR in the followup posted more
than two hours before yours: <news:1545664.d6rRysRUnX(a)PointedEars.de>

It makes sense then.

Please trim your quotes to the relevant minimum.

--
PointedEars
From: pk on
Thomas 'PointedEars' Lahn wrote:

>>>> The point is that you should quote it
>>>>
>>>> "$MDIR"/{load,src}
>>>>
>>>> The 'for' construct has no problem with that.
>>>
>>> The quoted parameter does not expand equally in every case. For
>>> example, with
>>>
>>> MDIR='/windows/c/Documents and Settings/PointedEars'
>
> MDIR='/windows/c/Documents and Settings/'
>
>>> (and a corresponding file
>
> /windows/c/Documents and Settings/PointedEars
>
>>> existing) the `for' parameter
>>>
>>> "$MDIR"/Pointed*
>>>
>>> expands to
>>>
>>> '/windows/c/Documents and Settings/Pointed*'

# MDIR="/windows/c/Documents and Settings"
# mkdir -p "$MDIR"
# touch "$MDIR/PointedEars"
# for i in "$MDIR"/Pointed*; do echo "$i"; done
/windows/c/Documents and Settings/PointedEars
From: moonhkt on
On 3¤ë30¤é, ¤W¤È6®É14¤À, pk <p...(a)pk.invalid> wrote:
> Thomas 'PointedEars' Lahn wrote:
> >>>> The point is that you should quote it
>
> >>>> "$MDIR"/{load,src}
>
> >>>> The 'for' construct has no problem with that.
>
> >>> The quoted parameter does not expand equally in every case. For
> >>> example, with
>
> >>> MDIR='/windows/c/Documents and Settings/PointedEars'
>
> > MDIR='/windows/c/Documents and Settings/'
>
> >>> (and a corresponding file
>
> > /windows/c/Documents and Settings/PointedEars
>
> >>> existing) the `for' parameter
>
> >>> "$MDIR"/Pointed*
>
> >>> expands to
>
> >>> '/windows/c/Documents and Settings/Pointed*'
>
> # MDIR="/windows/c/Documents and Settings"
> # mkdir -p "$MDIR"
> # touch "$MDIR/PointedEars"
> # for i in "$MDIR"/Pointed*; do echo "$i"; done
> /windows/c/Documents and Settings/PointedEars- ÁôÂóQ¤Þ¥Î¤å¦r -
>
> - Åã¥Ü³Q¤Þ¥Î¤å¦r -

Thank a lot. This script for perpare tar file for code migration from
UAT machine to Live machine.
Try on AIX 5.3

for i in "$MDIR"/{load,src} not work on AIX.
tst_ls.ksh[7]: /phx/migration/{load,src}: not found.

Try on AIX not work.Just list current directory
$ /bin/ls -p | sed '/[\/=@|]/d'
abc.txt

List of file and directory
drwxrwxrwx 3 moonhkt adg 256 Mar 30 09:54 load
drwxrwsrwx 2 moonhkt phx 256 Mar 30 09:24 src
-rw-rw---- 1 moonhkt adg 176 Mar 29 17:06 abc.txt
drwxrwxrwx 2 moonhkt adg 256 Mar 29 09:26 metrics
drwxrwxrwx 2 moonhkt adg 256 Mar 26 09:15 scube
drwxrwxrwx 2 moonhkt adg 256 Mar 26 09:15 utility

FYI, For my testing, I does not know how to get /phx/migration/load/
load-01 using -name .
#!/bin/ksh
# AIX 5.3(a)OFFICE, cygwin(a)HOME
MDIR=/phx/migration
for i in $MDIR/load $MDIR/src
do
( cd $i && (
CURRDIR=`pwd`
find $i ! -type d
#find $i ! -type d \( -name "*." -o \
# -name "*.p" -o -name "*.i" -o -name "*.v" -o \
# -name "*.ksh" -o -name "*.sh" -o -name "*.inc" -o
\
# -name "*.txt" -o -name "*.csv" \)
#find $i ! -type d
#find /phx/migration/ ! -type d -name *.*
)
)
done


Result
phx/migration/load/abc/abc.p
/phx/migration/load/load-01
/phx/migration/load/load-01.20100330mm
/phx/migration/load/load-01.inc
/phx/migration/load/abc.ksh
/phx/migration/src/abc.p
/phx/migration/src/a2.p
/phx/migration/src/a2.i
/phx/migration/src/mod-001
/phx/migration/src/abc.v
/phx/migration/src/mod.p
From: Thomas 'PointedEars' Lahn on
pk wrote:

> Thomas 'PointedEars' Lahn wrote:
>>>>> The point is that you should quote it
>>>>>
>>>>> "$MDIR"/{load,src}
>>>>>
>>>>> The 'for' construct has no problem with that.
>>>>
>>>> The quoted parameter does not expand equally in every case. For
>>>> example, with
>>>>
>>>> MDIR='/windows/c/Documents and Settings/PointedEars'
>>
>> MDIR='/windows/c/Documents and Settings/'
>>
>>>> (and a corresponding file
>>
>> /windows/c/Documents and Settings/PointedEars
>>
>>>> existing) the `for' parameter
>>>>
>>>> "$MDIR"/Pointed*
>>>>
>>>> expands to
>>>>
>>>> '/windows/c/Documents and Settings/Pointed*'
>
> # MDIR="/windows/c/Documents and Settings"
> # mkdir -p "$MDIR"
> # touch "$MDIR/PointedEars"
> # for i in "$MDIR"/Pointed*; do echo "$i"; done
> /windows/c/Documents and Settings/PointedEars

ACK, I must have confused the client and server screens while testing.
Unlike the client, the server has no `PointedEars' subdirectory, so ...


PointedEars