Printing next line with sed

后端 未结 2 981
萌比男神i
萌比男神i 2021-01-14 19:13

I want to print next line of matching word with sed.

I tried this command but it gives error :

sed -n \'// { N p}/\' test.x         


        
2条回答
  •  野的像风
    2021-01-14 20:04

    what about grep -e -A 1 regex? It will print line below regex.

    With sed, looking for pattern "dd", below works fine as you would:

    sed -n '/dd/ {n;p}' file
    

    For file content:

    dd
    aa
    ss
    aa
    

    It prints:

    aa
    

提交回复
热议问题