Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using awk with ls -l - help!

Status
Not open for further replies.

linuxtricks

IS-IT--Management
May 24, 2000
111
0
0
US
hi all.

I am using ls -l to list the contents of a directory, but, I only want to see the filenames and sym link information and not the other information before it.

i.e.
ls -l /folder

lrwxrwxrwx 1 root root 15 Aug 4 17:04 symfile -> _folder/otherfile
drwxr-xr-x 2 root root 4096 Aug 4 17:04 _folder

I'd like to only see the following:

symfile -> _folder/otherfile
_folder

Is there a way to show the contents in this way? Can I use awk to specify which columns to show? -or not show?

THanks in advance!


---
Try not. Do. Or do not. There is no try.
 
how aabout:
find . \( -type f -o -type l \)

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Something like this ?
ls -l /folder | awk '{print substr($0,44)}'
You may have to change the hardcoded 44 col position value.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
hi, vgersh99

Thanks for the reply.
The find command you supplied doesn't seem to show symbolic links.

hi PHV,

I am using:
ls -l /folder/ | awk '{print substr($0,56)}'
and it works superbly!!!

Many Thanks! (I will read the man page for awk to try and figure out what awk is actually doing).

=)

---
Try not. Do. Or do not. There is no try.
 
Hi:

Add the -follow option to find:

find . -follow \( -type f -o -type l \)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top