Guide
Building tar, find, grep, sed and awk commands correctly
Five commands do most of the everyday text and file work on Linux and macOS: tar packs and unpacks archives, find locates files, grep searches inside them, sed edits text and awk works with columns. Each has dozens of options and a few traps, so people search for the same examples again and again. This builder fills in the flags from a form, quotes arguments safely and explains in plain English what the command will do.
tar
Choose create, extract or list, and a compression: gzip for .tar.gz, bzip2 for .tar.bz2, xz for .tar.xz or zstd for .tar.zst. When creating, list the files and folders and any patterns to exclude, such as node_modules; each becomes an --exclude option. When extracting, -C chooses the target folder and --strip-components drops leading folders from the archive’s paths, useful for release tarballs that wrap everything in a versioned folder.
find
Pick a start folder and combine tests: name patterns (case-sensitive or not), type, size above or below a value, and age in days with -mtime, where +30 means older than 30 days. A folder to skip is written with the -path … -prune -o idiom so find does not even descend into it. Then decide what happens with the matches: print them, count them, run a command on them in batches with -exec … {} + or xargs -0, or delete them.
grep
Search a pattern recursively, case-insensitively, as whole words or inverted, as a fixed string or an extended regular expression, with line numbers, only file names or counts per file, and context lines around each match. --include limits the search to file types and --exclude-dir skips folders such as .git. The builder adds -- before the pattern, so a pattern that starts with a dash is not mistaken for an option.
sed and awk
For sed’s substitute command, the builder picks a delimiter that does not occur in your text, so replacing paths needs no escaping, and escapes &, which sed would otherwise replace with the matched text. In-place editing has two spellings: GNU sed on Linux takes -i.bak, BSD sed on macOS needs -i '.bak' or -i ''. For awk, set the field separator, the columns to print, a filter on one column and whether to skip a header line, or sum a column instead.
Worked examples
The default find command is find /var/log -type f -name '*.log' -mtime +30 -print, which lists log files older than 30 days. The tar defaults give tar -czf backup-2026-10-30.tar.gz --exclude=node_modules --exclude='*.log' site config. The sed defaults produce sed -i.bak 's|http://example.com|https://example.com|g' index.html, using | because the text contains slashes. For awk, awk -F , 'NR > 1 && $3 > 100 { print $1, $3 }' orders.csv prints the first and third columns of rows whose third column is above 100.
Habits that prevent accidents
Run find with Print before switching to Delete, and sed without -i before editing in place; the builder warns about both. Keep the backup suffix on in-place edits until you trust the command. Read the explanation line under each command: if it does not describe what you meant, the flags are wrong.
Related tools
- rsync Command Builder copies the folders you archived.
- Chmod Calculator works out the mode for find -exec chmod.
- Regex Tester helps build grep and sed patterns.
- Crontab Generator schedules a cleanup command.
Checked against the current version of the Linux Command Builder on .

