- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: 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
08-31-2001 08:13 AM
08-31-2001 08:13 AM
May be a simple question
I want a help to write one script.My requirement is search for a string and grep the next line to the line having the string(not the same line).
Any idea
thanks in advance
G.kumar
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2001 08:25 AM
08-31-2001 08:25 AM
Re: script
In perl:
#!/usr/local/bin/perl
open(FILE,"filename") || die "can't open file\n";
$string_match=0;
while
{
if (string_match == 1){
print "$_ is your next line";
}
if (/string/) {
next;
$string_match=1;
}
else{
next;
}
}#end of while
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2001 08:29 AM
08-31-2001 08:29 AM
Re: script
Try something like this:
# awk '/token1/ {getline;if (/token2/) {print $0}}' myfile
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2001 08:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2001 08:40 AM
08-31-2001 08:40 AM
Re: script
If I understand you correctly then this should do it:-
Cat
If the data is in a column format :-
dataA dataB DataC DataD
and you wish to just pick out the "dataC" column then
Cat
HTH
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2001 08:45 AM
08-31-2001 08:45 AM
Re: script
Let me make sure I understand your question.
Do you want to search to see what files contain a given string, then read the line after the line that contains this string, grepping for a second string?
If not, could you please clarify.
It also may become more complicated if you are recursively searching a directory or file system, since you would need to issue a find command to generate a list of files, then use loop to do a grep against each item in the list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2001 10:11 AM
08-31-2001 10:11 AM
Re: script
Thanks for the reply.
"sed" works.
one more question...
If my string is variable can i use sed ?
thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2001 10:18 AM
08-31-2001 10:18 AM
Re: script
Yes you can...
sed -n '/'$YOUR_VARIABLE'/,$p' your_file |sed -n '2p'
Please note those single quotes on $YOUR_VARIABLE.
-Sri