tail -f log.txt &
echo 'New log entry' >> log.txt
echo 'Another entry' >> log.txt
echo 'ERROR: Connection failed' >> log.txt
jobs
kill %1
What This Does
Pro Tips
Common Mistakes to Avoid
grep ERROR log.txt
grep berry fruits.txt
grep -i error log.txt
grep -n ERROR log.txt
grep -v ERROR log.txt
What This Does
Pro Tips
-i for case-insensitive search-n shows line numbers-v inverts match (show what doesn't match)-r searches directories recursivelyCommon Mistakes to Avoid
find . -name '*.txt'
find . -name 'log*'
find ~ -name 'fruits.txt'
find . -type f
find . -type d
What This Does
Pro Tips
-name is case-sensitive-iname for case-insensitive-type f = files only-type d = directories onlyCommon Mistakes to Avoid
find . -name '*.txt'
find . -name 'log*'
find ~ -name 'fruits.txt'
find . -type f
find . -type d
What This Does
Pro Tips
-name is case-sensitive-iname for case-insensitive-type f = files only-type d = directories onlyCommon Mistakes to Avoid
cat log.txt | grep ERROR
ls -l | grep txt
find . -name '*.txt' -exec grep ERROR {} \;
What This Does
| (pipe) sends output of one command to input of next. cat | grep searches file contents. ls | grep filters directory listings. find -exec runs command on each result. |
Pro Tips
| chains commands together |
| Common: ls | grep pattern |
| Common: cat file | grep search |
| Can chain multiple pipes: cat file | grep ERROR | grep -v DEBUG |
Common Mistakes to Avoid
| Confusing | (pipe) with > (redirect) |
| Complex -exec syntax (easier to use find | xargs) |
echo -e 'DEBUG: Starting\nINFO: Processing\nERROR: Failed\nWARN: Retrying\nINFO: Success' > app.log
grep ERROR app.log
grep -E 'ERROR|WARN' app.log
tail -n 5 app.log | grep -v DEBUG
What This Does
| grep -E enables extended regex. | combines pattern matching. Real DevOps: filter logs, find errors, exclude debug lines. These patterns solve daily tasks. |
Pro Tips
| grep -E ‘pattern1 | pattern2’ matches either pattern |
| Real-world: tail -f /var/log/app.log | grep ERROR (monitor for errors) |
Common Mistakes to Avoid
| Not using -E for OR patterns ( | needs -E flag) |
cd ~
rm -r search-practice
ls
What This Does
Pro Tips
Common Mistakes to Avoid