- Community Home
- >
- Servers and Operating Systems
- >
- Operating System - HP-UX
- >
- System Administration
- >
- Print last filename
-
- Forums
-
Blogs
- Alliances
- Around the Storage Block
- Behind the scenes @ Labs
- HPE Careers
- HPE Storage Tech Insiders
- Infrastructure Insights
- Inspiring Progress
- Internet of Things (IoT)
- My Learning Certification
- OEM Solutions
- Servers: The Right Compute
- Shifting to Software-Defined
- Telecom IQ
- Transforming IT
- Infrastructure Solutions German
- L’Avenir de l’IT
- IT e Trasformazione Digitale
- Enterprise Topics
- ИТ для нового стиля бизнеса
- Blogs
-
Quick Links
- Community
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Contact
- Email us
- Tell us what you think
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Enterprise.nxt
- Marketplace
- Aruba Airheads Community
-
Forums
-
Blogs
-
InformationEnglish
- 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
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
07-08-2009 03:45 AM
07-08-2009 03:45 AM
Print last filename
I need to print last file name when executing "ls -ltr" command from a fixed path.
Example:
$ls -ltr
-rw-rw-rw- 1 RT R1 6922674 Jul 8 14:08 abc123
-rw-rw-rw- 1 RT R1 6922674 Jul 8 14:10 abc124
-rw-rw-rw- 1 RT R1 6922674 Jul 8 14:15 abc125
-rw-rw-rw- 1 RT R1 6922674 Jul 8 14:20 abc126
-rw-rw-rw- 1 RT R1 6922674 Jul 8 14:25 abc126
-rw-rw-rw- 1 RT R1 6922674 Jul 8 14:30 abc127
-rw-rw-rw- 1 RT R1 6922674 Jul 8 14:40 abc128
-rw-rw-rw- 1 RT R1 6922674 Jul 8 14:50 abc129
-rw-rw-rw- 1 RT R1 6922674 Jul 8 15:08 abc130
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
07-08-2009 03:49 AM
07-08-2009 03:49 AM
Re: Print last filename
#ls -ltr | tail -1
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
07-08-2009 03:54 AM
07-08-2009 03:54 AM
Re: Print last filename
It's not clear exactly what you mean, so:
# ls -ltr | awk 'END{print $NR}'
abc130
# ls -ltr | tail -1
-rw-rw-rw- 1 RT R1 6922674 Jul 8 15:08 abc130
# ls -ltr | awk '{print $NF}'
abc123
abc124
abc125
abc126
abc126
abc127
abc128
abc129
abc130
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
07-08-2009 04:31 AM
07-08-2009 04:31 AM
Re: Print last filename
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
07-08-2009 04:39 AM
07-08-2009 04:39 AM
Re: Print last filename
> i just need to print "abc130".
# ls -ltr | awk 'END{print $NR}'
abc130
...as I said...
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
07-08-2009 04:58 AM
07-08-2009 04:58 AM
Re: Print last filename
Or leave out the long listing and print first:
$ ls -t | head -1
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
07-08-2009 05:17 AM
07-08-2009 05:17 AM
Re: Print last filename
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
07-08-2009 05:23 AM
07-08-2009 05:23 AM
Re: Print last filename
If you are satistied with the answers you have received, please read:
http://forums.itrc.hp.com/service/forums/helptips.do?#28
Assigning points is both a way of saying "thank you" and a way of showing future readers of your thread what helped you solve your problem.
Most of your threads have no points assigned. You can review those, too, by examining your own profile:
http://forums.itrc.hp.com/service/forums/publicProfile.do?userId=WW217887&forumId=1
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
07-08-2009 08:08 PM
07-08-2009 08:08 PM
Re: Print last filename
-NKG-
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2019 Hewlett Packard Enterprise Development LP