Results 1 to 4 of 4
  1. #1
    Join Date
    May 2003
    Posts
    27

    Question Unanswered: How can I list filename only in aix?

    example:
    under a directory name mydir, I have the following files....

    /mydir $ ls -al
    total 9
    drwxrwxr-x 3 db2adm00 grpdba 512 Nov 18 14:14 .
    drwxr-xr-x 19 db2adm00 grpdba 3584 Nov 18 14:12 ..
    -rw-rw-r-- 1 db2adm00 grpdba 0 Nov 18 14:14 .myhiddenfile
    -rw-rw-r-- 1 db2adm00 grpdba 0 Nov 18 14:13 mybackup.tgz
    -rw-rw-r-- 1 db2adm00 grpdba 0 Nov 18 14:12 myfile.txt
    lrwxrwxrwx 1 db2adm00 grpdba 10 Nov 18 14:13 mylink -> myfile.txt
    drwxrwxr-x 2 db2adm00 grpdba 512 Nov 18 14:12 mysubdir


    1. how can I list the normal file like the following?
    mybackup.tgz
    myfile.txt

    2. how can I list the normal file and the hidden file like the following?
    .myhiddenfile
    mybackup.tgz
    myfile.txt

    3. how can I just exclude the directory name?
    .myhiddenfile
    mybackup.tgz
    myfile.txt
    mylink


    anyone please help, thanks for advance :-)

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    Re: How can I list filename only in aix?

    There may be options in ls for what you want, but I don't know any of them ...

    I do in the following way :

    1) Have to give a thought

    2) ls -al | grep ^- | nawk '{print $NF}'

    3) ls -la | grep -c ^d | nawk '{print $NF}'


    HTH

    Sathyaram


    Originally posted by r390gt1
    example:
    under a directory name mydir, I have the following files....

    /mydir $ ls -al
    total 9
    drwxrwxr-x 3 db2adm00 grpdba 512 Nov 18 14:14 .
    drwxr-xr-x 19 db2adm00 grpdba 3584 Nov 18 14:12 ..
    -rw-rw-r-- 1 db2adm00 grpdba 0 Nov 18 14:14 .myhiddenfile
    -rw-rw-r-- 1 db2adm00 grpdba 0 Nov 18 14:13 mybackup.tgz
    -rw-rw-r-- 1 db2adm00 grpdba 0 Nov 18 14:12 myfile.txt
    lrwxrwxrwx 1 db2adm00 grpdba 10 Nov 18 14:13 mylink -> myfile.txt
    drwxrwxr-x 2 db2adm00 grpdba 512 Nov 18 14:12 mysubdir


    1. how can I list the normal file like the following?
    mybackup.tgz
    myfile.txt

    2. how can I list the normal file and the hidden file like the following?
    .myhiddenfile
    mybackup.tgz
    myfile.txt

    3. how can I just exclude the directory name?
    .myhiddenfile
    mybackup.tgz
    myfile.txt
    mylink


    anyone please help, thanks for advance :-)
    Visit the new-look IDUG Website , register to gain access to the excellent content.

  3. #3
    Join Date
    Jun 2002
    Location
    UK
    Posts
    525
    You could also take a look at the 'test' command (man test).

    e.g.

    for file in *
    do
    test -f $file && echo $file
    done

  4. #4
    Join Date
    Feb 2003
    Posts
    4

    Re: How can I list filename only in aix?

    Originally posted by r390gt1
    example:
    under a directory name mydir, I have the following files....

    /mydir $ ls -al
    total 9
    drwxrwxr-x 3 db2adm00 grpdba 512 Nov 18 14:14 .
    drwxr-xr-x 19 db2adm00 grpdba 3584 Nov 18 14:12 ..
    -rw-rw-r-- 1 db2adm00 grpdba 0 Nov 18 14:14 .myhiddenfile
    -rw-rw-r-- 1 db2adm00 grpdba 0 Nov 18 14:13 mybackup.tgz
    -rw-rw-r-- 1 db2adm00 grpdba 0 Nov 18 14:12 myfile.txt
    lrwxrwxrwx 1 db2adm00 grpdba 10 Nov 18 14:13 mylink -> myfile.txt
    drwxrwxr-x 2 db2adm00 grpdba 512 Nov 18 14:12 mysubdir


    1. how can I list the normal file like the following?
    mybackup.tgz
    myfile.txt

    2. how can I list the normal file and the hidden file like the following?
    .myhiddenfile
    mybackup.tgz
    myfile.txt

    3. how can I just exclude the directory name?
    .myhiddenfile
    mybackup.tgz
    myfile.txt
    mylink


    anyone please help, thanks for advance :-)
    Not sure I understand what you're asking for exactly, but here goes:

    1. ls
    2. ls -a
    3. ls -aF|grep -v /
    (not sure exact ls option but this will work)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •