Added Lab7

This commit is contained in:
Theodotos Andreou 2018-06-30 12:17:52 +03:00
bovenliggende 26ed50b695
commit ccf021823e
2 gewijzigde bestanden met toevoegingen van 102326 en 0 verwijderingen

102305
Lab7/matches.txt Normal file

Diff onderdrukt omdat het te groot bestand Laad Diff

21
Lab7/regex.examples Normal file
Bestand weergeven

@ -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 lines end
grep "[[:space:]]$" matches.txt # find whitespace at the lines 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