Browse Source

Added Lab7

master
Theodotos Andreou 5 years ago
parent
commit
ccf021823e
2 changed files with 102326 additions and 0 deletions
  1. +102305
    -0
      Lab7/matches.txt
  2. +21
    -0
      Lab7/regex.examples

+ 102305
- 0
Lab7/matches.txt
File diff suppressed because it is too large
View File


+ 21
- 0
Lab7/regex.examples View File

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

Loading…
Cancel
Save