Linux Intermediate Summary — Text Processing and Shell Scripts
This article is part of the Linux Course, where you master practical Linux skills from scratch, from basic commands through to shell scripting.
One page that pulls together grep regex, sed, awk, sort uniq cut wc tr tee, tar ln diff, and du df date, plus the shell syntax for variables, arguments, conditionals, loops, functions, input, combining commands, and output — with category maps and a cheat table for each area.
An Overview of What You Learned in Linux Intermediate
This page has no browser exercise — it's a full round-up of the intermediate level (text processing I1–I10 and shell scripting S1–S10). It brings both sides together on one page, with diagrams and a cheat table for each area: the text processing side — searching and substituting, summarizing columns, reshaping, archiving, diffs, system info — and the shell scripting side, from variables and functions through reading input, combining commands, and writing reports. Use the cheat tables as an index: when something needs a refresher, jump straight back to the article it came from.
Cheat Sheet — Regular Expressions, sed, awk
This is the core group for searching, substituting, extracting, and aggregating text. Narrow lines down with grep's regular expressions, substitute and manipulate lines with sed, and pull out columns and aggregate them with awk. Once you have these symbols down, working with logs and CSV files gets much easier.
| Syntax | Meaning |
|---|---|
^ / $ | Match the start or end of a line |
. / * | Any single character / zero or more of the preceding item |
[abc] / [a-z] | Character class (any one of them, or a range) |
grep -E | Extended regex (+ | () become available) |
grep -o | Print only the matching part |
| Syntax | Meaning |
|---|---|
sed 's/old/new/' | Replace the first old on each line with new |
sed 's/old/new/g' | Replace every old on the line |
sed -n 'Np' | Extract only line N |
sed '/pat/d' | Delete lines containing pat |
sed -i | Rewrite the file in place |
| Syntax | Meaning |
|---|---|
awk '{print $1}' | Pull out column 1 ($NF is the last column) |
awk -F',' | Change the separator |
NR / NF | Line number / number of fields on that line |
/pat/{ … } | Apply the action only to matching lines |
BEGIN{} … END{} | Set up before processing and aggregate after |
Cheat Sheet — Shaping Tools and File Commands
These are the shaping tools for sorting, removing duplicates, extracting columns, counting lines, translating characters, and splitting output, plus the file commands for archives, links, diffs, and system info. Chain them with pipes to prepare data for aggregation and reports.
| Syntax | Meaning |
|---|---|
sort / sort -n | Sort (-n sorts numerically) |
uniq / uniq -c | Drop consecutive duplicates (-c adds the count) |
cut -d',' -f1 | Extract a column with a given separator |
wc -l / wc -w | Count lines / words |
tr a-z A-Z / tr -d / tr -s | Translate, delete, and squeeze repeated characters |
tee file | Split output to both the screen and a file |
| Syntax | Meaning |
|---|---|
tar -cf a.tar dir | Bundle a directory into one file (uncompressed) |
tar -tf a.tar | List an archive's contents |
tar -xf a.tar / -C dir | Extract (-C picks the destination) |
ln -s target name | Create a symbolic link (the -> in ls -l) |
ln a b | Create a hard link |
diff a b / diff -u | Show the differences (-u is the unified format) |
du -sh / df -h | Show usage and free space in readable units |
date +%Y-%m-%d / uname -a | Format the date and show kernel info |
Cheat Sheet — Shell Script Syntax
This is the syntax from variables, arguments, conditionals, loops, and functions through reading input, combining commands, and output. Start with #!/bin/sh, add execute permission with chmod +x, and run it with ./file. This course's console is ash, so use [ ] with if ([[ ]] is a bash extension).
| Syntax | Meaning |
|---|---|
#!/bin/sh / chmod +x f / ./f | Shebang, adding execute permission, running |
v=x / "$v" | Assign and reference a variable (quote it to be safe) |
$1 / $@ / $# | First argument / all arguments / argument count |
${1:-def} | Default value when the argument is missing |
$(...) / $(( )) | Command substitution / arithmetic expansion |
[ -f f ] / if … fi / case | File tests and conditional branching |
for … do … done / while | Repeat a block of commands |
name() { … } / local | Defining a function and local variables |
while read line; do … done < f | Read a file one line at a time |
printf '%s\t%s\n' a b | Formatted output (explicit tab and newline) |
> f / >> f / 2> err | Overwrite, append, and split standard error off |
<<EOF … EOF / $? | here-doc / the most recent exit code |
Nice work on the intermediate level!
You now have the full set: searching with regular expressions, substituting and aggregating with sed / awk, shaping with sort / uniq / cut / wc / tr / tee, and file work with tar / ln / diff and the system-info commands. On the scripting side you have variables, arguments, conditionals, loops, and functions, through reading input, combining commands, and writing reports. Put them together and you can handle most everyday work on a real system, from summarizing logs to automating routine tasks.
Keep this cheat sheet handy, and when you forget a piece of syntax, go back to the relevant article and try it hands-on. From here, put what you've learned together and write a small automation script for something you actually do day to day.