- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How do I truncate words?
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
01-03-2003 07:19 AM
01-03-2003 07:19 AM
How do I truncate words?
I'm programming in shell. But I have a small problem.
I want a command or a program to truncate words, for example:
AS-CHIMBOTE ... I want to get .... CHIMBOTE
AS-RIMAC ...... I want to get .... RIMAC
AS-PIURA ...... I want to get .... PIURA
AS-ICA ........ I want to get .... ICA
AS-SANISIDRO-2 I want to get .... SANISIDRO-2
AS-VILLA-MONT-2 I want to get .... VILLA-MONT-2
I want to truncate the 3 first characters of every word.
There are words that have more than one dash(-).
Please, I need a command to truncate words.
Thank you very much!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2003 07:24 AM
01-03-2003 07:24 AM
Re: How do I truncate words?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2003 07:25 AM
01-03-2003 07:25 AM
Re: How do I truncate words?
awk '{print substr($0,4)}' your_file
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2003 07:39 AM
01-03-2003 07:39 AM
Re: How do I truncate words?
sed 's/...//' datafile
Regards,
Robert Thorneycroft
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2003 09:44 AM
01-03-2003 09:44 AM
Re: How do I truncate words?
x="AS-SANISIDRO-2"
y=${x#*-}
echo $y
will display-
SANISIDRO-2
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2003 10:08 AM
01-03-2003 10:08 AM
Re: How do I truncate words?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2003 10:39 AM
01-04-2003 10:39 AM
Re: How do I truncate words?
Just a minor point, whilst your command will be correct for the examples given it will not truncate the first three characters of every word as specified in the question IF any other examples do not start with AS-.
In this case your command will fail so the solution I mentioned above will be better as it will truncate the first three characters of every word, no matter what they are.
Of course if every line does start AS- your command will work without any problems however.
Regards,
Robert Thorneycroft