AWK and SED
AWK and SED
file.txt
Line 1
Line 2
Line 3
Line 4
Commands:
example.txt
Hello, world!
This is a test.
Welcome to the world of sed.
Enjoy your day!
Commands:
To substitute sed 's/world/universe/g' example.txt
Insert sed -i 's/world/universe/g' example.txt
Serach sed –n ‘/[hH]ello/p’ example.txt
PRINT LINE $ sed -n '$=' example.txt
Sed script as separate file
data.txt
script.sed
AWK EXAMPLES
script.awk
BEGIN {
print "-------------------"
{
if ($2 > 30) {
printf "%-18s %s\n", $1, $2 # Print the name and age with formatting
END {
data.txt
John Doe,25
Jane Smith,30
Alice Johnson,28
Bob Brown,35
Charlie Green,40
Command :