1
0
Fork 0
LPIC-1_101-400/Lab7/regex.examples

22 linhas
1.4 KiB
Plaintext
Original Anotar Histórico

Este arquivo contém caracteres Unicode ambíguos

Este arquivo contém caracteres Unicode que podem ser confundidos com outros caracteres. Se você acha que isso é intencional, pode ignorar esse aviso com segurança. Use o botão Escapar para revelá-los

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