Day 3 of my #1HourADayJourney. Today's lab was all about File Content Inspection. When you're managing a database, you spend a lot of time looking at logs. Here is my technical summary:
📖 Reading Files
Instead of opening a full editor, these commands are much faster:
-
cat -n: View file with line numbers. -
head -n5: Look at the first 5 lines. -
tail -c6: Look at the last 6 bytes (useful for checking specific EOF markers). -
grep "pattern": Search for specific strings within a file.
🔄 Redirection (The Power of > vs >>)
I practiced combining files:
bash
cat file1 file2 > mixtext.txt # Overwrites the file
cat file1 >> mixtext.txt # Appends to the end of the file
⚖️ Comparing Data
This is the most interesting part. Using diff to see what changed between files:
bash
diff file1 file2 # Line-by-line comparison
diff -r dir1 dir2 # Recursive directory comparison
Self-Correction Today: I tried cat -n1 and got an error. Learned that cat uses -n for lines, while head and tail use -n [number]. Tiny details matter in CLI!
Follow my journey: #1HourADayJourney
Top comments (0)