![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi,
I am new to shell scripting. I want to execute a task here. In a file test.sh, there occurs a string test. I am now writing a script in another file ( let it be example.sh). How can i print the next line from test.sh from the occurrence of the string xxx. In detail, I want to print the next line to the line in which a string xxx is there in the file test.sh. Thanks, Prakash. ![]() |
|
||||
|
Hi,
Thanks for your replies. I tried Franklin's reply. Its working but there is one problem with it. In my file the string xxx will occur many times. But I want to print the line next to the string xxx which is in the line with another string yyy In detail, I will check for string yyy. If the line which has yyy also contains a string xxx, I want to print the next line to that line . Please help me in doing that. I did not try to execute manosubsulo's reply as I did not get him correctly what actually he mean with his n and p. Thanks, Prakash. |
|
||||
|
Hi, Thanks for your reply but its not working
i think the error may be in writing yyy there. Actually this yyy is the word which i am searching for. I am giving yyy as the command line to get the output. So in your reply i am using awk '/$1/ && /xxx/{getline;print}' file I have also tried with awk '/grep $1/ && /xxx/{getline;print}' file but nothing worked. Actually the line i am using to print is as below cat abc.sh| grep $1 | grep Failure | awk '/grep $1/ && /Failure/{getline;print;exit}' /root/shell/abc.sh Here abc.sh is the file on which i am doing this. Here $1 is the word yyy as mentioned above. This statement is another file in the same location /root/shell/ Thanks, Prakash. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|