- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Print in awk
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2005 03:57 PM
06-28-2005 03:57 PM
Print in awk
I want to print the last colum using awk. the column number may very
drwxrwxr-x 2 tariq users 1024 Jun 27 13:36 .
drwxr-xr-x 5 tariq users 1024 Jun 27 12:11 ..
-rw-rw-r-- 1 tariq users 5 Jun 27 13:36 test
w-rw-r-- 1 tariq users 6 Jun 10 09:38 file01
-rw-rw-r-- 1 tariq users 7 Jun 10 09:38 file02
-rw-rw-r-- 1 tariq users 7 Jun 10 09:39 file03
from the above putput i want to print only
test
file01
file02
file03
How can i do that. I cannot use print $4 as sometime the file name will be in different column.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2005 04:14 PM
06-28-2005 04:14 PM
Re: Print in awk
Sorry if I'm misunderstanding you, but can you not use:
$ ls -l | awk '{print $9}' | grep -v "^.[?]"
OR alternatively use:
$ ls -l | awk '{print $NF}' | grep -v "^.[?]"
Cheers
Con
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2005 06:45 PM
06-28-2005 06:45 PM
Re: Print in awk
ls -l | awk '{ print $NF }'
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2005 07:02 PM
06-28-2005 07:02 PM
Re: Print in awk
another solution but similiar as others
from me;
ls -lrt|grep -v "^d"|awk '{print $NF}'
Good Luck,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2005 07:06 PM
06-28-2005 07:06 PM
Re: Print in awk
directories so you can get only files...
good luck,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2005 09:41 PM
06-30-2005 09:41 PM
Re: Print in awk
if you really want to list files only, try
ls -p | awk '!/[@/]'
It's fast and you need not bother with filenames containing spaces.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2005 10:01 PM
06-30-2005 10:01 PM
Re: Print in awk
# ls -l | perl -ne 'split(/ /); $var=@_; $var-=1;print $_[$var];'
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2005 07:52 AM
07-15-2005 07:52 AM
Re: Print in awk
Regards,
Brian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2005 08:23 AM
07-15-2005 08:23 AM
Re: Print in awk
# ls -1
cheers!