Guest User

Untitled

a guest
Jan 19th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. ([^:]*):(.*)
  2.  
  3. sed 's/([^:]*):(.*)/1/' /etc/passwd
  4.  
  5. 1st Capturing Group ([^:]*)
  6.  
  7. Match a single character not present in the list below [^:]*
  8. * Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
  9. : matches the character : literally (case sensitive)
  10. : matches the character : literally (case sensitive)
  11. 2nd Capturing Group (.*)
  12. .* matches any character (except for line terminators)
  13. * Quantifier — Matches between zero and unlimited times, as many times
  14.  
  15. sed 's/([^:]*):
  16. /([^:]*): Match the string till you see a colon `:` and group.
  17.  
  18. sed (.*)/1/' /etc/passwd
  19. (.*) Match everything after `:` and group
  20.  
  21. sed 's/([^:]*):(.*)/12/' <<<"Hello:Unix:Users"
  22. HelloUnix:Users
  23.  
  24. sed 's/([^:]*):(.*)/1;2/' <<<"Hello:Unix:Users"
  25.  
  26. sed 's/([^:]*):(.*)/1 Linux and 2/' <<<"Hello:Unix:Users"
  27.  
  28. (any symbol except : repeated zero or more times):(any symbol remeated zero or more times)
  29.  
  30. sed -r 's/([^:]*):(.*)/1/' /etc/passwd
  31.  
  32. root
  33. daemon
  34. bin
  35. sys
  36. sync
  37. games
Add Comment
Please, Sign In to add comment