Working with Text: Viewing, Searching, and Piping
Master the everyday text tools every Linux admin relies on: viewing files, searching with grep, and chaining commands with pipes and redirection to process server data directly from the command line.
Working with Text: Viewing, Searching, and Piping is a free Linux Server Deployment & SSH Mastery lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Linux Server Deployment & SSH Mastery learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Text Is the Linux Interface
On a Linux server, almost everything is text — configs, logs, output. Reading and filtering it fluently with pipes and redirection is what makes you an admin.
Viewing Files with cat and less
cat dumps a whole file to the screen — fine for short ones. For long files use less, which lets you scroll, search with /, and quit with q.
cat /etc/hostname
less /var/log/syslogPeeking with head and tail
Just need the start or end? head shows the first lines, tail the last. And tail -f follows a file live — perfect for watching logs grow.
head -n 5 /etc/passwd
tail -n 20 /var/log/auth.log
tail -f /var/log/nginx/access.logSearching with grep
grep finds lines matching a pattern — the workhorse of log analysis. Reach for -i (ignore case), -n (line numbers), and -r (recurse a directory).
grep -i 'failed' /var/log/auth.log
grep -rn 'TODO' /etc/nginx/The Power of the Pipe
A pipe (|) feeds one command's output into the next, letting you chain simple tools. Here grep filters cat's output for you.
cat /var/log/syslog | grep -i 'usb'Counting with wc
wc counts lines, words, and characters. Pipe into wc -l and you can answer questions like how many failed logins happened.
grep -i 'failed password' /var/log/auth.log | wc -lSorting and Deduplicating
sort orders lines and uniq collapses adjacent duplicates — so you almost always sort first. uniq -c tallies counts, great for ranking entries.
cut -d' ' -f1 access.log | sort | uniq -c | sort -rn | headRedirecting Output to Files
Redirection saves output to a file: > overwrites, >> appends, and 2> captures errors. That's how scripts build reports and logs.
grep -i error /var/log/syslog > errors_today.txt
date >> errors_today.txtEditing Streams with sed
sed edits a text stream on the fly with s/old/new/. It prints the changed version without touching the original — unless you add -i.
sed 's/localhost/myserver/g' /etc/hostsPutting It Together
The real skill is composing these tools. One line can pull the top offending IPs from a web log: read, extract, sort, count, rank, show the top five.
cat access.log | awk '{print $1}' | sort | uniq -c | sort -rn | head -n 5Best Practices
Keep text wrangling clean: prefer less for big files, build pipelines one stage at a time, use >> to avoid clobbering data, and quote your grep patterns.
Quick Check
Test your text-processing knowledge.
Recap
You've got a full text toolkit: view with cat/less/head/tail, search with grep, transform with wc/sort/uniq/sed, and compose it all with pipes and redirection.
Frequently asked questions
Is the “Working with Text: Viewing, Searching, and Piping” lesson free?
Yes — the full text of “Working with Text: Viewing, Searching, and Piping” is free to read here on the web, and the Linux Server Deployment & SSH Mastery course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Linux Server Deployment & SSH Mastery course, upgrade to CoddyKit PRO.
What will I learn in “Working with Text: Viewing, Searching, and Piping”?
Master the everyday text tools every Linux admin relies on: viewing files, searching with grep, and chaining commands with pipes and redirection to process server data directly from the command line. You practise Linux Server Deployment & SSH Mastery with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Linux Server Deployment & SSH Mastery?
No prior experience is required. Linux Server Deployment & SSH Mastery on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Working with Text: Viewing, Searching, and Piping” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Linux Server Deployment & SSH Mastery lesson?
Yes. Every Linux Server Deployment & SSH Mastery lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Introduction to Linux Servers
- Mastering Basic CLI Commands
- File System & Permissions Essentials
- Working with Text: Viewing, Searching, and Piping