BashWars
How to build bash oneliners
grep
Search string without case sensative
grep -i 'example' input.txtCounting the number of matches
grep -c 'example' input.txtSearch with regex
grep -E 'example[0-9]+' input.txtPrinting strings without matches
grep -v 'example' input.txtcut
Retrieving characters in a range
cut -c 5-10 input.txtExtracting fields using a delimiter
sort
Sort strings alphabetically
To sort strings in reverse order:
Sorting numeric values
Removing duplicates when sorting
uniq
Remove duplicate strings
Count duplicate strings
tr
Replacing characters
Remove characters
Case conversion
head & tail
Printing the first N lines
Printing the last N lines
xargs
Passing arguments to a command
Limiting the number of arguments
Applying a command in parallel
find
Find file by name
Find file by size
3. Find and execute command
wc
Count strings in file
Count word in file
Count symbols in file
AWK
Take info from output by column
Count strings in file
Delete empty strings in file
Sum column values
Counting unique values โโin a column
sed
Replacing text
Delete strings
Inserting text after a line
Replace text only on certain lines
Removing the first N rows
Printing Specific Strings
jq
Format string to json
Retrieving a value by key
Filtering array elements
JSON structure conversion
Retrieving all values โโof a specific key
Counting elements in an array
Replacing values โโin JSON
Last updated