Braineos
DiscoverChallenges
Sign in
← Back to decks
Sign in to save your progress, vote, and build your own decks.Sign in

bash hacks

commands to make for small, perhaps even simple, but very powerful utility

8 cards·by perchslayer
Study this deck

Where this fits

command line

No other decks with this tag yet.

hacks

No other decks with this tag yet.

bash

No other decks with this tag yet.

linux

No other decks with this tag yet.

commands

No other decks with this tag yet.

How to sort an unsorted list of data with duplicate entries and generate a nicely formated report from the result.
cat unsorted_list_with_dupes.txt | sort | uniq | pr | lpr
How to Input a poorly formatted text file and dress it up for read and printability.
cat poorly_formatted_report.txt | fmt | pr | lpr
How to input a text file of a list of unsorted items and generate a sorted list text file.
[me@linuxbox me]$ sort < file_list.txt > sorted_file_list.txt
How to display a list of directories and how much space they consume, sorted from the largest to the smallest, using pipes
du | sort -nr
How to display the total number of files in the current working directory and all of its subdirectories, using a pipe.
find . -type f -print | wc -l
How to display the 10 newest files in the current directory, using a pipe.
ls -lt | head
What is "grep" and what does it do ?
A FILTER command that examines each line of data it receives from standard input and outputs every line that contains a specified pattern.
What is "uniq" and what does it do ?
A FILTER command, given a sorted stream of data from standard input, it removes duplicate lines of data (makes sure every line is unique).