Zest.

Bash: sed and awk one-liners

A short, tested Bash example for sed and awk one-liners. Copy it and adjust the names and paths for your project.

Bash
sed -i 's/old/new/g' file.txt            # replace in place
sed -n '5,10p' file.txt                  # print lines 5 to 10
awk '{print $1}' file.txt                # first column
awk -F, '{print $2}' data.csv            # second CSV column
awk '{s += $1} END {print s}' nums.txt   # sum a column

Find it in Zest

Search for “bash sed and awk one-liners” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More Bash examples

All Bash examples