- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Sed display only last 8 character of filename.
Operating System - Linux
1753342
Members
5159
Online
108792
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
тАО10-30-2009 05:38 AM
тАО10-30-2009 05:38 AM
Sed display only last 8 character of filename.
I would like to display the last 8 characters of the filenames for filenames of different lengths.
I can delete the last 8 characters with sed but dont know how to only show the last 8 characters.
The filenames are something like;
afxH340800340000
afxH30800340021
afxR3080034002122
I have used;
echo $file | sed -e 's/........$//g'
Any help is greatly apprecaited.
Cheers
Ben
I can delete the last 8 characters with sed but dont know how to only show the last 8 characters.
The filenames are something like;
afxH340800340000
afxH30800340021
afxR3080034002122
I have used;
echo $file | sed -e 's/........$//g'
Any help is greatly apprecaited.
Cheers
Ben
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-30-2009 05:48 AM
тАО10-30-2009 05:48 AM
Re: Sed display only last 8 character of filename.
You could use:
awk '{ print substr($0,length($0)-8,length($0)) }' file
awk '{ print substr($0,length($0)-8,length($0)) }' file
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-30-2009 06:17 AM
тАО10-30-2009 06:17 AM
Re: Sed display only last 8 character of filename.
Here's how to solve it with sed:
echo $file | sed -e 's/^.*\(........\)$/\1/g'
MK
echo $file | sed -e 's/^.*\(........\)$/\1/g'
MK
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-30-2009 06:32 AM
тАО10-30-2009 06:32 AM
Re: Sed display only last 8 character of filename.
Thanks guys, I ended up solving this with
echo "afxH340800340000" | sed -e 's/.*\(.\{8\}\)$/\1/'
echo "afxH340800340000" | sed -e 's/.*\(.\{8\}\)$/\1/'
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP