Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. Test 1
  2. Test 2
  3. Test 3
  4. Test 4
  5. UNIX
  6. Test 5
  7. Test 6
  8. Test 7
  9. Test 8
  10. Test 9
  11.  
  12. Test 5
  13. Test 6
  14.  
  15. $ awk '$0 == "UNIX" {i=1;next};i && i++ <= 2' file
  16. Test 5
  17. Test 6
  18.  
  19. grep -A2 -P '^UNIX$' file
  20.  
  21. awk '$0=="UNIX"{getline; print; getline; print}' file
  22.  
  23. sed -n '/^UNIX$/{n;p;n;p}' file
  24.  
  25. grep -A 2 UNIX file.txt
  26.  
  27. -A NUM, --after-context=NUM
  28. Print NUM lines of trailing context after matching lines.
  29. Places a line containing -- between contiguous groups of
  30. matches.
  31.  
  32. sed -n '/UNIX/{n;p;n;p}' /path/to/file
  33.  
  34. $ for i in {1..9}; do echo $i; done | sed -n '/4/{n;p;n;p}'
  35. 5
  36. 6
  37.  
  38. ex -s +'1,/UNIX/d|%p|q!' file_or_/dev/stdin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement