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-26-2002 09:05 PM
09-26-2002 09:05 PM
I have a requirement. I want to grep the lines which contains SEV word and from that output I want to cut SEV to end of the line.
Ex:
SEV word1 word2
Word1 SEV Word2
Word1 word2 SEV word4 word4
word word word without SEV
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2002 09:21 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2002 09:28 PM
09-26-2002 09:28 PM
Re: Script
grep SEV inputfile |
while read line
do
line=${line#*SEV}
print "SEV $line"
done
this will print from the first occurance of SEV
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2002 09:32 PM
09-26-2002 09:32 PM
Re: Script
grep SEV inputfile |
while read line
do
line=${line#*SEV}
print "SEV $line"
done
this will print from the first occurance of SEV
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2002 09:38 PM
09-26-2002 09:38 PM
Re: Script
Thanks a lot.
I tried first option. It is working fine. I had to add -n option with sed.
If possible can you tell what sed command does.
I am not getting.
Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2002 10:14 PM
09-26-2002 10:14 PM
Re: Script
this substitutes 'replacement' for 'pattern'. the p flag prints the line if a successful substitution is done.
the regular expersion used for the pattern consists of:
'.' which matches any single character except newline.
'*' which matches any number (including zero) of the single character (including a character specified by a regular expression) that immediately precedes it.
\(\) saves the pattern enclosed between '\(' and '\)' into a special holding space (to a maximum of nine). They can be replayed in substitutions by the escape sequences \1 to \9.
\n matches the nth pattern previously saved by '\(' and '\)', where the previously saved patterns are counted from the left on the line.
so this substitution breaks the line into 3 patterns. .* for everything up to SEV. (this does means the line cannot begin with SEV). Then SEV and lastly everything after SEV (has to have at least one character). So, for the substitution to be performed the line must have a least one character before SEV and at least one character after. In which case the patterns 2 (SEV) and # (everything after SEV) will be printed.
a more exact sed command would be:
sed -e '/^SEV .*/p' -e 's/\(.*\)\(SEV .*\)/\2/p'
this will print the line if it starts with SEV, a blank and at least one character. The substitution will print from SEV to the end of the line only if SEV is followed by a blank space and at least one more character.
my previous sed command
sed 's/\(.*\)\(SEV\)\(.*\)/\2\3/p' sort of cheats a bit SEV followed by just a blank character will be printed. The cheat assumes that if there is a blank space it will be followed by a word.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2002 03:37 PM
09-27-2002 03:37 PM
Re: Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2002 07:36 AM
09-29-2002 07:36 AM
Re: Script
N/A