From: moonhkt on
On Mar 29, 9:03 pm, pk <p...(a)pk.invalid> 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.

Thank a lot.

#!/bin/ksh
# aix 5.3
MDIR=/phx
for i in $MDIR/{load,utility,src}
do
cd $i
find $i ! -type d -print
done

Result as below, But How to filter out backup copy *.yyyymmdd_hhss ?
$ test_ls.ksh
/phx/load/abc
/phx/load/abc.20100326_2301
/phx/load/abc.20100327_1338
/phx/load/abcd
/phx/utility/abc1.ksh
/phx/utility/ut001.p
/phx/utility/ut002.p
/phx/src/abc.p
From: Janis Papanagnou on
moonhkt wrote:
> On Mar 29, 9:03 pm, pk <p...(a)pk.invalid> 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.
>
> Thank a lot.
>
> #!/bin/ksh
> # aix 5.3
> MDIR=/phx
> for i in $MDIR/{load,utility,src}
> do
> cd $i
> find $i ! -type d -print
> done
>
> Result as below, But How to filter out backup copy *.yyyymmdd_hhss ?

Have you inspected the man page of find (or grep)?

> $ test_ls.ksh
> /phx/load/abc
> /phx/load/abc.20100326_2301
> /phx/load/abc.20100327_1338
> /phx/load/abcd
> /phx/utility/abc1.ksh
> /phx/utility/ut001.p
> /phx/utility/ut002.p
> /phx/src/abc.p
From: Thomas 'PointedEars' Lahn on
moonhkt wrote:

> On Mar 29, 9:03 pm, pk <p...(a)pk.invalid> 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.

> [...]
> MDIR=/phx
> for i in $MDIR/{load,utility,src}
> do
> cd $i
> find $i ! -type d -print
> done

That is pointless, and a standalone -print is superfluous. You only need
this one line (and no script file at all):

find $MDIR/{load,utility,src} ! -type d

> Result as below, But How to filter out backup copy *.yyyymmdd_hhss ?

man find | less -p '-regex pattern'


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

> moonhkt wrote:
>> [...]
>> MDIR=/phx
>> for i in $MDIR/{load,utility,src}
>> do
>> cd $i
>> find $i ! -type d -print
>> done
>
> That is pointless, and a standalone -print is superfluous. You only need
> this one line (and no script file at all):
>
> find $MDIR/{load,utility,src} ! -type d

find /phx/{load,utility,src} ! -type d


PointedEars
From: Sidney Lambe on
On comp.unix.shell, Thomas 'PointedEars' Lahn <PointedEars(a)web.de> wrote:
> moonhkt wrote:
>
>> I try to list out all the files under particular directory. Some files
>> without extension.
>
> Filename extension is a WinDOS concept. This is comp.*unix*.shell.
>
>> How to ignore Directory by ls ?
>
> One wonders if you ever RTFM before posting.

He obviously meant that one couldn't use the existence of
extensions to select only non-directory files with wildcards.

Many files in Linux have extensions and their are quite a few
common apps and utilities that won't accept files if they don't
have the preper extensions. Like gunzip.

Using the file "todo" as an example:

$gzip todo
$mv todo.gz todo
$gunzip todo
gzip: todo: unknown suffix -- ignored

You are a stupid and ignorant jerk.

<plonk>

[delete]

Sid