Labs for LPIC-1_101-400
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
1.4KB

  1. grep a matches.txt # find lines containing 'a'
  2. grep ab matches.txt # find lines containing 'abc'
  3. grep '^ab$' matches.txt # find lines starting with 'abc'
  4. grep "[hat]" matches.txt # find lines containing h, a or t
  5. grep -E "[abc]{3,4}" matches.txt # find strings with 3 or 4 successive combination of a, b or c
  6. grep -E -n -o "[abc]{3,4}" matches.txt # show line numbers and matches only
  7. ip addr | egrep "([0-9]{1,3}\.){3}[0-9]{1,3}" # find IP addresses
  8. ip addr | egrep "([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}" # find MAC Addresses
  9. grep "[[:punct:]]" matches.txt # find punctuation
  10. grep "[linux]{3,5}" regex.examples # find l,i,n,u, or x in a pattern between 3 to 5 characters
  11. egrep "[linux]{3,5}" regex.examples # did it work now?
  12. grep '[[:alpha:]]' regex.examples # find lettes
  13. fgrep '[[:alpha:]]' regex.examples # find the single quote enclosed string explicitly
  14. grep "[[:blank:]]" matches.txt # find space or tab
  15. grep "[[:space:]]" matches.txt # find all whitespace
  16. grep "[[:blank:]]$" matches.txt # find space or tab at the line’s end
  17. grep "[[:space:]]$" matches.txt # find whitespace at the line’s end
  18. grep -i uuid /etc/fstab # find the 'uuid' string
  19. sed -e 's/UUID/uuid' /etc/fstab | grep uuid # case sensitive
  20. sed 's/UUID/UUID UUID/' /etc/fstab | sed 's/UUID/uuid/' # replace only the first match of UUID
  21. sed 's/UUID/UUID UUID/' /etc/fstab | sed 's/UUID/uuid/g' # replace all matches of UUID