Linux Summer Training 23
By Ahmed Khaled, 29/Aug/23
Text processing
yees?
yes please?�
Outcomes
Agenda
Simple commands
Regex
02
Awk
05
Grep
03
Summary
06
01
04
Sed
Simple commands
Sort
Options
Rev
Uniq
Options
Cut
Options
Example
Tr
Options
Hands on
Sort�Rev
Uniq
Cut (-c, -f, -d)
Tr
Hands on�Solution!
Paste
Options
Recap
Regex
Example
Regex symbols
1 or more of the previous char
+
0 or 1 of the previous (optional)
0 or more of the previous (‘+’ and ‘?’)
Anything
Characters, digits, spaces, word breaks
Beginning , end of line
?
*
.
\w, \d, \s, \b
^, $
Regex symbols
Character sets (^ -> except)
[ ]
Ranges {4} , {4, } , {4,5}
Grouping
Reference
{ }
( )
\1, \2
OR operator
|
Regex applications
BREAK
Grep
Options
Hands on
Ex: ahmed@gmail.com
Ex: Ahmed#1010
Sed
Syntax
sed “s/pattern/replace/flags” file.txt
Sed options
Detect ‘/’s
Detect pattern in a line first (/ /)
Delete (d)
Multiple sed commands
Insert (&)
Hands on
Hands on�Solution!
Awk
How it works
Syntax
awk ‘/pattern/ {action}’ file.txt
Example
Awk features
Arithmetic
If conditions + &&, ||
Relational expressions (~, !~, >)
Range patterns (,)
Begin, end
C = (F – 32) * 5/9
Hands on�Solution!
Summary
Outcomes
Thanks!