Guest User

Untitled

a guest
Dec 12th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. This is an PLUTO
  2. This is PINEAPPLE
  3. This is ORANGE
  4. This is RICE
  5.  
  6. PLUTO:
  7. This is an PLUTO
  8. PINEAPPLE:
  9. This is an PINEAPPLE
  10. ORANGE:
  11. This is an ORANGE
  12. RICE:
  13. This is an RICE
  14.  
  15. $ awk '{ print $NF ":"; print }' file
  16. PLUTO:
  17. This is an PLUTO
  18. PINEAPPLE:
  19. This is PINEAPPLE
  20. ORANGE:
  21. This is ORANGE
  22. RICE:
  23. This is RICE
  24.  
  25. awk '{ print $NF ":" ORS $0 }' file
  26.  
  27. awk '{ printf("%s:n%sn", $NF, $0) }' file
  28.  
  29. $ sed 'h; s/.* //; s/$/:/; G' file
  30. PLUTO:
  31. This is an PLUTO
  32. PINEAPPLE:
  33. This is PINEAPPLE
  34. ORANGE:
  35. This is ORANGE
  36. RICE:
  37. This is RICE
  38.  
  39. h; # Put the pattern space (the current line) into tho hold space (general purpose buffer)
  40. s/.* //; # Remove everything up to the last space character in the pattern space
  41. s/$/:/; # Add colon at the end
  42. G; # Append the hold space (original line) with an embedded newline character
  43. # (implicit print)
  44.  
  45. awk '{$0=$NF":n"$0}1' file
Add Comment
Please, Sign In to add comment