If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > How can I list filename only in aix?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-18-03, 01:15
r390gt1 r390gt1 is offline
Registered User
 
Join Date: May 2003
Posts: 27
Question 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 :-)
Reply With Quote
  #2 (permalink)  
Old 11-18-03, 07:56
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,543
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


Quote:
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.
Reply With Quote
  #3 (permalink)  
Old 11-18-03, 09:01
Damian Ibbotson Damian Ibbotson is offline
Padawan
 
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
Reply With Quote
  #4 (permalink)  
Old 01-06-04, 10:08
astralvoid astralvoid is offline
Registered User
 
Join Date: Feb 2003
Posts: 4
Re: How can I list filename only in aix?

Quote:
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)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On