- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Shell Script - Parsing 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
Forums
Discussions
Discussions
Forums
Discussions
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
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-28-2003 10:16 AM
08-28-2003 10:16 AM
[0:2] x.x.a start=3 end=50 items=47 aaa bbb ccc
[3:4] x.x.b start=20 end=70 items=50 aaa bbb ..
I want to parse this and create a new file with the format
x.x.a 50
x.x.b 70
Please note that I want to extract the second string and number in 4th string and ignore rest of the line and write into a new file.
How do I do it in Shell Scripts ?
I am a beginner in Shell Scripts..
Any help is appreciated..
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2003 10:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2003 10:28 AM
08-28-2003 10:28 AM
Re: Shell Script - Parsing Question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2003 10:28 AM
08-28-2003 10:28 AM
Re: Shell Script - Parsing Question
# cut -d" " -f2,4 your_file | sed 's/end=//' > new_file
Hai
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2003 10:28 AM
08-28-2003 10:28 AM
Re: Shell Script - Parsing Question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2003 10:28 AM
08-28-2003 10:28 AM
Re: Shell Script - Parsing Question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2003 10:38 AM
08-28-2003 10:38 AM
Re: Shell Script - Parsing Question
# awk -F"=" 'awk -F= {split($1,a," ");X=a[2];split($4,a," ");print X,a[1]}' inputfile
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2003 10:40 AM
08-28-2003 10:40 AM
Re: Shell Script - Parsing Question
Oops. that should be:
# awk -F"=" 'awk -F= {split($1,a," ");X=a[2];split($3,a," ");print X,a[1]}' inputfile
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2003 10:41 AM
08-28-2003 10:41 AM
Re: Shell Script - Parsing Question
Oops. that should be:
# awk -F"=" 'awk -F= {split($1,a," ");X=a[2];split($3,a," ");print X,a[1]}' inputfile
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2003 12:17 PM
08-28-2003 12:17 PM
Re: Shell Script - Parsing Question
or if the 'end=' is always 'end=', and there will never be leading whitespace
# perl -pe's/^\S+\s+(\S+).*?end=(\d+).*/$1 $2/' inile
It's not always awk/sed/sh :))
Enjoy, have FUN! H.Merijn