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.

A category map of the intermediate commands
regexgrep / -E / -osubstitute/extractsed s/// -n pcolumns, totalsawk $1 BEGIN ENDshapesort uniq cut wcconvert, branchtr tee xargsfilestar ln diffinfodu df date unameshell basics#!/bin/sh chmod +xcontrol, combineif for fn $(...)text processingshaping and filessystem and scripts
Nine areas in all: text processing (regex, sed, awk, shaping), file commands, system info, and shell scripting.
A cheat sheet of shell script structure
shebang#!/bin/shvariablesv=x "$v"arguments$1 $@ ${1:-d}conditions[ -f ] if caseloopsfor whilefunctionsname(){} localinputwhile read < fcombining$(grep|awk)output>> here-doc $?declaration and argumentscontrol structuresinput and output
From the shebang through variables, arguments, conditionals, loops, functions, input, combining commands, and output — these are the building blocks of a script.

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.

SyntaxMeaning
^ / $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 -EExtended regex (+ | () become available)
grep -oPrint only the matching part
SyntaxMeaning
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 -iRewrite the file in place
SyntaxMeaning
awk '{print $1}'Pull out column 1 ($NF is the last column)
awk -F','Change the separator
NR / NFLine 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.

SyntaxMeaning
sort / sort -nSort (-n sorts numerically)
uniq / uniq -cDrop consecutive duplicates (-c adds the count)
cut -d',' -f1Extract a column with a given separator
wc -l / wc -wCount lines / words
tr a-z A-Z / tr -d / tr -sTranslate, delete, and squeeze repeated characters
tee fileSplit output to both the screen and a file
SyntaxMeaning
tar -cf a.tar dirBundle a directory into one file (uncompressed)
tar -tf a.tarList an archive's contents
tar -xf a.tar / -C dirExtract (-C picks the destination)
ln -s target nameCreate a symbolic link (the -> in ls -l)
ln a bCreate a hard link
diff a b / diff -uShow the differences (-u is the unified format)
du -sh / df -hShow usage and free space in readable units
date +%Y-%m-%d / uname -aFormat 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).

SyntaxMeaning
#!/bin/sh / chmod +x f / ./fShebang, 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 / caseFile tests and conditional branching
for … do … done / whileRepeat a block of commands
name() { … } / localDefining a function and local variables
while read line; do … done < fRead a file one line at a time
printf '%s\t%s\n' a bFormatted output (explicit tab and newline)
> f / >> f / 2> errOverwrite, 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.