- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script/awk/sed question
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
Discussions
Discussions
Forums
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
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
тАО08-07-2002 04:50 AM
тАО08-07-2002 04:50 AM
Contents of text file:
1234 qwer Phone 123-123-1234
76 wejyf Phone 567-325-8765
Phone 983-876-3241 3 deddfgh
q Phone 000-335-6593 ddi555
Want output to be:
Phone 123-123-1234
Phone 567-325-8765
Phone 983-876-3241
Phone 000-335-6593
What would be the best way to accomplish this? Thanks in advance.
Duke
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2002 04:59 AM
тАО08-07-2002 04:59 AM
SolutionAssume the data is in file yourData.
Assume you need 18 columns (characters) at the end (Phone xxx-xxx-xxxx).
grep Phone yourData | sed -e "s/.*Phone/Phone/" | cut -c1-18
grep finds the pattern.
sed deletes characters in front of the pattern.
cut keeps the number of characters you want.
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2002 05:06 AM
тАО08-07-2002 05:06 AM
Re: Script/awk/sed question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2002 05:13 AM
тАО08-07-2002 05:13 AM
Re: Script/awk/sed question
This should work as well.
# sed 's/^.*Phone/Phone/' text_file | awk '{print $1 " " $2}'
Hai
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2002 06:02 AM
тАО08-07-2002 06:02 AM
Re: Script/awk/sed question
sed 's/.*\(Phone [^ ]*\).*/\1/' filename
Rgds, Robin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2002 07:03 AM
тАО08-07-2002 07:03 AM