gbash

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 -d

base64

Base64 encode or decode data.

echo "hello" | base64
echo "aGVsbG8K" | base64 -d

column

Format input into columns.

echo -e "name age\nalice 30\nbob 25" | column -t

comm

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 file1

cut

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 characters

diff

Compare files line by line.

diff file1.txt file2.txt
diff -u old.txt new.txt                     # unified format

grep

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 match

Output the first part of files.

head file.txt                               # first 10 lines
head -n 5 file.txt
head -c 100 file.txt                        # first 100 bytes

join

Join lines of two files on a common field.

join file1.txt file2.txt
join -t',' -1 2 -2 1 a.csv b.csv

nl

Number lines of files.

nl file.txt
nl -ba file.txt                             # number all lines including blanks

paste

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 mode

printf

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                          # olleh

sed

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 lines

seq

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 10

sort

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 field

split

Split a file into pieces.

split -l 100 big.txt chunk_                 # 100 lines per file
split -b 1m big.bin part_                   # 1 MB per file

tac

Concatenate and print files in reverse line order.

tac file.txt

tail

Output the last part of files.

tail file.txt                               # last 10 lines
tail -n 20 file.txt
tail -c 100 file.txt                        # last 100 bytes

tee

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 files

tr

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 digits

uniq

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 duplicates

wc

Print newline, word, and byte counts.

wc file.txt
wc -l file.txt                              # line count only
wc -w file.txt                              # word count only

xan

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 view

Additional Search and Text Utilities

These commands are also part of the default registry:

CommandDescription
basencEncode or decode data using base16, base32, base64, base64url, and related alphabets
csplitSplit files by line number, repeated patterns, or regex boundaries
egrepgrep compatibility alias for extended regular expressions
expandConvert tab characters into spaces
fgrepgrep compatibility alias for fixed-string matching
foldWrap long lines to a target width
fmtReflow plain text paragraphs to a readable width
numfmtConvert numbers between raw and human-readable forms
odInspect files as octal, hexadecimal, decimal, or character dumps
prPaginate and columnize text for terminal or print-style output
ptxGenerate permuted indexes for words in text
shufRandomize lines or number ranges
stringsExtract printable strings from binary files
tsortTopologically sort dependency edges from stdin or a file
unexpandConvert runs of spaces back into tabs

For flags and shell-facing help text, run help <command> inside gbash.