Buy CSG Merchandise:
tee.pub/lic/csg
Patreon page: / computers_servers
This video is based on RHEL 8.
Video to cover the section 'Use grep and regular expressions to analyse text' for the RHCSA (Red Hat Certified System Administrator).
More information on the required learning: www.redhat.com...
Summary of the common regular expressions:
[ ]: Matches any one of a set characters
[ ] with hyphen: Matches any one of a range characters
^: The pattern following it must occur at the beginning of each line
^ with [ ] : The pattern must not contain any character in the set specified
$: The pattern preceding it must occur at the end of each line
. (dot): Matches any one character
\ (backslash): Ignores the special meaning of the character following it
*: Zero or more occurrences of the previous character
(dot).*: Nothing or any numbers of characters.
Commands used in this video:
[ ] : Matches any one of a set characters:
$grep "[CcFf]a[RrTt]" kafka.txt
Use [ ] with hyphen: Matches any one of a range characters:
$grep "da[a-z]" kafka.txt
$grep "da[a-i][a-z]" kafka.txt
Use ^: The pattern following it must occur at the beginning of each line:
$grep "^He" kafka.txt
Display list of directories only:
$ls -l |grep "^d"
Display list of regular files only:
$ls -l |grep "^-"
Use ^ with [ ]: The pattern must not contain any character in the set specified:
$grep "d[^a-i]e" kafka.txt
Use $: The pattern preceding it must occur at the end of each line:
$ grep "got$" kafka.txt
Use . (dot): Matches any one character:
$ grep "st..id" kafka.txt
Use \ (backslash): Ignores the special meaning of the character following it:
$ grep "out\.$" kafka.txt
$ grep "Hell\!" kafka.txt
Use *: zero or more occurrences of the previous character:
$ grep "hap*[e-z]n[a-i]d" kafka.txt
Use (dot).*: Nothing or any numbers of characters:
$ grep "hap.*ed" kafka.txt
8 окт 2024