- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Help for script...
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
09-20-2002 05:13 AM
09-20-2002 05:13 AM
I need to get a tape id from an output file.
In the output file I have a line like this:
Medium : [9d1c8029:3d888e10:0f0b:0001]
How can I "grep" only the code between the squares?
Regards...
PSS
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2002 05:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2002 05:19 AM
09-20-2002 05:19 AM
Re: Help for script...
You need to use something like awk, perl, sed, ...
Try this:
sed "s/^\(Medium : \[\)\(.*\)\(\]$\)/\2/"
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2002 05:22 AM
09-20-2002 05:22 AM
Re: Help for script...
ID=$(
This removes all text up to the first [ and after the final ].
You could also use the shell itself:-
DATA=${DATA#*\[} # remove text up to the first [
ID=${DATA%]} #remove the final ] and all after it
Regards,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2002 05:32 AM
09-20-2002 05:32 AM
Re: Help for script...
grep Medium "output file" | awk -F[ '{print $2}' |awk -F] '{print $1}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2002 05:32 AM
09-20-2002 05:32 AM
Re: Help for script...
cat thatoutputfilename |
grep "^Medium " |
sed "s/^\(Medium : \[\)\(.*\)\(\]$\)/\2/"
returns:
9d1c8029:3d888e10:0f0b:0001
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2002 06:07 AM
09-20-2002 06:07 AM
Re: Help for script...
perl -ne '/^Medium/ && print((split("[\\[\\]]",$a))[1]);'
or
perl -ne '/^Medium\s*:\s*\[(.*)\]/ && print $1'
HTH
-- Rod Hills