Search and Text Processing Commands
Commands for searching, filtering, transforming, and formatting text.
base32
Base32 encode or decode data.
echo "hello" | base32
echo "NBSWY3DP" | base32 -dbase64
Base64 encode or decode data.
echo "hello" | base64
echo "aGVsbG8K" | base64 -dcolumn
Format input into columns.
echo -e "name age\nalice 30\nbob 25" | column -tcomm
Compare two sorted files line by line.
comm file1.txt file2.txt
comm -12 file1.txt file2.txt # lines common to both
comm -23 file1.txt file2.txt # lines only in file1cut
Remove sections from each line.
echo "a:b:c" | cut -d: -f2 # b
cut -f1,3 -d',' data.csv
cut -c1-10 file.txt # first 10 charactersdiff
Compare files line by line.
diff file1.txt file2.txt
diff -u old.txt new.txt # unified formatgrep
Search for patterns in files.
grep "error" log.txt
grep -r "TODO" src/
grep -n -i "warning" *.log # line numbers, case-insensitive
grep -c "pattern" file.txt # count matches
grep -v "debug" log.txt # invert matchhead
Output the first part of files.
head file.txt # first 10 lines
head -n 5 file.txt
head -c 100 file.txt # first 100 bytesjoin
Join lines of two files on a common field.
join file1.txt file2.txt
join -t',' -1 2 -2 1 a.csv b.csvnl
Number lines of files.
nl file.txt
nl -ba file.txt # number all lines including blankspaste
Merge lines of files side by side.
paste names.txt scores.txt
paste -d',' col1.txt col2.txt # comma delimiter
paste -s file.txt # serial modeprintf
Format and print data.
printf "%s is %d years old\n" "Alice" 30
printf "%05d\n" 42 # 00042
printf -v msg "%s-%02d" "build" 7; echo "$msg"rev
Reverse lines character-wise.
echo "hello" | rev # ollehsed
Stream editor for filtering and transforming text.
sed 's/old/new/' file.txt
sed -i 's/foo/bar/g' file.txt # in-place
sed -n '5,10p' file.txt # print lines 5-10
sed '/^#/d' config.txt # delete comment linesseq
Print a sequence of numbers.
seq 5 # 1 2 3 4 5
seq 2 10 # 2 through 10
seq 0 2 10 # 0 2 4 6 8 10sort
Sort lines of text files.
sort file.txt
sort -n numbers.txt # numeric sort
sort -r file.txt # reverse
sort -u file.txt # unique lines only
sort -t',' -k2 data.csv # sort by second fieldsplit
Split a file into pieces.
split -l 100 big.txt chunk_ # 100 lines per file
split -b 1m big.bin part_ # 1 MB per filetac
Concatenate and print files in reverse line order.
tac file.txttail
Output the last part of files.
tail file.txt # last 10 lines
tail -n 20 file.txt
tail -c 100 file.txt # last 100 bytestee
Read from stdin and write to both stdout and files.
echo "hello" | tee output.txt
echo "hello" | tee -a output.txt # append
echo "hello" | tee a.txt b.txt # write to multiple filestr
Translate or delete characters.
echo "hello" | tr a-z A-Z # HELLO
echo "hello world" | tr -s ' ' # squeeze spaces
echo "hello123" | tr -d '0-9' # delete digitsuniq
Report or omit repeated lines (input must be sorted).
sort file.txt | uniq
sort file.txt | uniq -c # count occurrences
sort file.txt | uniq -d # only duplicateswc
Print newline, word, and byte counts.
wc file.txt
wc -l file.txt # line count only
wc -w file.txt # word count onlyxan
CSV toolkit for row, column, aggregation, reshape, and conversion operations.
xan headers data.csv
xan count data.csv
xan select 'name,email' data.csv
xan select 'vec_*' data.csv # glob column selection
xan filter 'age > 30' data.csv # expression filtering
xan groupby region 'sum(amount) as total' # grouped aggregation
xan explode tags data.csv # reshape rows
xan join id left.csv user_id right.csv # multi-file join
xan to json data.csv # CSV -> JSON
xan slice -s 1 -e 3 data.csv # row slicing
xan flatten -l 2 data.csv # vertical record viewAdditional Search and Text Utilities
These commands are also part of the default registry:
| Command | Description |
|---|---|
basenc | Encode or decode data using base16, base32, base64, base64url, and related alphabets |
csplit | Split files by line number, repeated patterns, or regex boundaries |
egrep | grep compatibility alias for extended regular expressions |
expand | Convert tab characters into spaces |
fgrep | grep compatibility alias for fixed-string matching |
fold | Wrap long lines to a target width |
fmt | Reflow plain text paragraphs to a readable width |
numfmt | Convert numbers between raw and human-readable forms |
od | Inspect files as octal, hexadecimal, decimal, or character dumps |
pr | Paginate and columnize text for terminal or print-style output |
ptx | Generate permuted indexes for words in text |
shuf | Randomize lines or number ranges |
strings | Extract printable strings from binary files |
tsort | Topologically sort dependency edges from stdin or a file |
unexpand | Convert runs of spaces back into tabs |
For flags and shell-facing help text, run help <command> inside gbash.