Skip to content

Instantly share code, notes, and snippets.

@heyalexej
Last active August 29, 2015 14:01
Show Gist options
  • Save heyalexej/717324e79e79d13b926f to your computer and use it in GitHub Desktop.
Save heyalexej/717324e79e79d13b926f to your computer and use it in GitHub Desktop.
vim updater.bash
bash updater.bash
vim updater.bash
apt-cache search gem
sudo gem install -V lolcat
cowthink heyhey
sudo apt-get install fortune
fortune
man fortune
fortune -o
man fortune
fortune -o
fortune
fortune | cowsay | lolcat
fortune
fortune | cowsay
fortune | cowsay | lolcat
top
ls
cd /
ls
ls -lah | lolcat
sudo apt-get install sl
sl | lolcat
sl
sl | lolcat
cd /
ls -lah | lolcat
wget http://introcs.cs.princeton.edu/java/data/dickens.txt
sudo apt-get install rubygems
sudo apt-get install ruby | gem
history
which ruby
ruby --version
sudo apt-get install rubygems
sudo apt-get -qq update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get install tmux
sudo apt-get upgrade -y vim
vim --version
ls
ll
pwd
top
ls
vim copyall.sh
ll /etc/skel/
vim copyall.sh
vim bootsrap.sh
bash bootsrap.sh
ls
mkdir
ls -lah
ll
mkdir userdata
cd userdata/
ls
mkdir names
cd names/
vim name-sources.txt
ls
cd ..
mkdir corpora && cd corpora
vim text-sources.txt
ls
cd userdata/
ls
cd corpora/
ls
ll
cowsay -d hello | lolcat
pinky | lolcat
pwd
sl
ls
pwd
cd ..
ls
mkdir funnythings
ls
cd funnythings/
ls
pwd
touch hello.txt
ls
man ls
ls -ah
man ls
ls -lah
echo hi
echo hi > hello.txt
ls -lah
cat hello.txt
echo bobba > hello.txt
cat hello.txt
echo lalala >> hello.txt
cat hello.txt
pinky >> pinky.txt
cat pinky.txt
man wc
cat pinky.txt
wc -l pinky.txt
pinky >> pinky.txt
wc -l pinky.txt
wc -w pinky.txt
pinky >> pinky.txt
wc -w pinky.txt
cat pinky.txt
cat pinky.txt | grep user007
man grep
cat pinky.txt | grep -C 2 user007
cat pinky.txt | grep user007
cat pinky.txt | grep user007 > superclient.txt
cat superclient.txt
ls
cat hello.txt
echo newtextfile > hello2.txt
ls
ls -lah
ls -lah | grep hello
cat hello*
cat hello* > hellocombined.txt
wc -l hellocombined.txt
cd ..
ls
cd
ls
ls
cd /
ls
cd home/
ls -lah
ls
tree
sudo apt-get install tree
tree
cd ..
cd
ls
ls
tree
ls
pwd
tree
cd names/
ls
cat name-sources.txt
cd
cd userdata/names/
ls
cat name-sources.txt
cd
cd userdata/names/
cat name-sources.txt
cat name-sources.txt | less
wget curl http://www.census.gov/genealogy/www/data/1990surnames/dist.female.first | awk '{print $1}'
wget curl http://www.census.gov/genealogy/www/data/1990surnames/dist.female.first
ls
cat name-sources.txt | less
cat name-sources.txt
ls
rm dist.female.first.1
ls
cat dist.female.first
wc -l dist.female.first
cd
cd userdata/names/
ll
cat dist.female.first
cat dist.female.first | less
cat dist.female.first
head dist.female.first
tail dist.female.first
cat dist.female.first
cat dist.female.first | sort
cat dist.female.first | sort -r
cat dist.female.first | cut -d -f1
cat dist.female.first | cut -d -k1
cat dist.female.first | cut -d'' -k1
cat dist.female.first | cut -d' ' -k1
cat dist.female.first | cut -d' ' -f1
cat dist.female.first
cat dist.female.first | cut -d' ' -f1
cat dist.female.first | cut -d' ' -f2
cat dist.female.first | cut -d' ' -f3
cat dist.female.first | cut -d' ' -f4
cat dist.female.first | cut -d' ' -f5
cat dist.female.first | cut -d' ' -f6
cat dist.female.first | cut -d'\t' -f6
cat dist.female.first | cut -d'\t' -f2
cat dist.female.first | cut -d't' -f2
man cut
cat dist.female.first | cut -f2
cat dist.female.first | awk '{ print $1 }'
cat dist.female.first | awk '{ print $2 }'
cat dist.female.first | awk '{ print $3 }'
cat dist.female.first | awk '{ print $4 }'
cat dist.female.first | awk '{ print $4 $1 }'
cat dist.female.first | awk '{ print $4,$1 }'
cat dist.female.first | awk '{ print $4 ## $1 }'
cat dist.female.first | awk '{ print $4 "##" $1 }'
cat dist.female.first | grep ann | awk '{ print $4 "##" $1 }'
cat dist.female.first | grep ann
cat dist.female.first | grep an
cat dist.female.first
cat dist.female.first | grep ann
cat dist.female.first | grep ANN
cat dist.female.first | grep ANN | awk '{ print $4 "##" $1 }'
cat dist.female.first | grep ANN | awk '{ print $4 "\t" $1 }'
cat dist.female.first | grep ANN | awk '{ print $4 "group :ann" $1 }'
cat dist.female.first | grep ANN | awk '{ print $4 "\tgroup :ann\t" $1 }'
cat dist.female.first | grep ANN | awk '{ print $4 "\tgroup :ann\t" $1 }' | wc -l
ls
cat name-sources.txt
wget http://www.census.gov/genealogy/www/data/1990surnames/dist.male.first
ls
cat dist.* | grep ANN | awk '{ print $4 "\tgroup :ann\t" $1 }' | wc -l
cat dist.male.first | grep ANN | awk '{ print $4 "\tgroup :ann\t" $1 }' | wc -l
cat dist.male.first | grep ANN | awk '{ print $4 "\tgroup :ann\t" $1 }'
ls
diff dist.female.first dist.male.first
man diff
diff dist.female.first dist.male.first
diff dist.female.first dist.male.first | less
ls
wc -l dist.*
cat dist*
cat dist* > dist.combined.names
ls
ls -l
wc -l dist.female.first dist.male.first
cat dist.female.first dist.male.first | md5sum
cat dist.combined.names | md5sum
cat dist.combined.names
echo .
echo . >> dist.combined.names
cat dist.combined.names
cat dist.combined.names | md5sum
cat dist.female.first dist.male.first | md5sum
vim dist.combined.names
cat dist.combined.names | md5sum
echo "hi potch" | md5sum
echo "hi patch" | md5sum
cat dist.combined.names
man tr
cat dist.combined.names | tr -cd [:upper:] [:lower:]
man tr
cat dist.combined.names | tr [:upper:] [:lower:]
cd ..
ls
cd corpora/
ll
cat text-sources.txt
wget http://introcs.cs.princeton.edu/java/data/dickens.txt
wc -l dickens.txt
wc -w dickens.txt
head dickens.txt
tail dickens.txt
cat dickens.txt | less
cat dickens.txt | tr -sc 'A-Za-z' '\12' | tr -d [:punct:] | tr [:upper:] [:lower:]
cat dickens.txt | tr -sc 'A-Za-z' '\12' | tr -d [:punct:] | tr [:upper:] [:lower:] | tr -d '\r' | sort | uniq -c | sort -nr > output_ngram.txt
cat output_ngram.txt
wc -l output_ngram.txt
output_ngram.txt
cat output_ngram.txt
head output_ngram.txt
tail output_ngram.txt
cat dickens.txt | grep -C 2 -i abbeville
cat dickens.txt | grep -C 4 -i abbeville
cat output_ngram.txt
cat output_ngram.txt | lolcat
cat output_ngram.txt | sort
man sort
cat output_ngram.txt | sort -n
cat dickens.txt | grep -i face
cat output_ngram.txt | wc -l
vim filename.txt
cat filename.txt
ls
w
pinky
history
pwd
cat .bash_history

Launch the Terminal

Mac

Use + space to open the Spotlight menu to start a search. Type Terminal, pick the matching application and hit enter. You can speed up the process by [assigning a shortcut] 17.

Linux

CTRL + ALT + t will do the trick.

Windows

Win + r or just Win and then type cmd, hit enter.

Commands we used

You can find the original .bash_history from my machine below.

  • [vim]
  • [awk]
  • [cat]
  • [cd]
  • [cowsay] 14
  • [cp]
  • [curl]
  • [cut]
  • [find]
  • [grep]
  • [head]
  • [history]
  • [lolcat] 13
  • [ls]
  • [mkdir]
  • [mv]
  • [ping]
  • [pwd]
  • [sort]
  • [tail]
  • [top]
  • [touch]
  • [tr]
  • [tree]
  • [uniq]
  • [wget]
  • [less]

For all commands you can use:

$ <command> --help

and / or

$ man <command>

By default, man uses less as its pager. In less, you can use:

  • h to get help
  • q to quit
  • Space or F to advance one page
  • D to advance half a page
  • B to go back one page
  • U to go back half a page
  • /pattern search forward for (N-th) matching line
  • ?pattern search backward for (N-th) matching line
  • n repeat previous search (for N-th occurrence)
  • N repeat previous search in reverse direction
  • &pattern display only matching lines

Package Managers for Mac

  • [Homebrew] 1 2781 "formulas"¹
  • [Fink] 2 20787 "packages"¹
  • [MacPorts] 3 18487 "ports"¹

"Of these, my favorite is Homebrew. Homebrew is very light and lean, and ideal for people who just want to install some select packages to augment the Darwin base system.

Both Fink and MacPorts work around Darwin by existing in their own little ecosystems. When installing something that depends on another tool that already exists in Darwin, these package managers tend to install their own copies of those tools instead of using the one already on the system. There are some compatibility advantages to this, but at the same time, there is some confusion when there are multiple copies of libraries and binaries on the same system.

Homebrew takes the other approach, relying on what is provided in the Darwin base system instead of replicating everything itself. It augments Darwin instead of treating it as unreliable and building its own little world." [Source] 4

Homebrew is insanely easy to install and you normally shouldn't run into any issues.

$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

After the installation is complete you will be able to install "formulas" as easy as this:

$ brew install <packagename>

Shells for Windows

  • [Babun] 19
  • [Console2] 20
  • [Cygwin] 21
  • Cmd
  • PowerShell

If you just need something to SSH into a Linux server, give [PuTTY] 22 or [PuTTYTray] 23 (which is based on the former) a shot.

Package Managers for Windows

  • [chocolatey] 5 1837 "packages"¹
  • [Npackd] 6 667 "packages"¹ ²

Unfortunately I have no clue at all about the Windows world. Google is your friend here.

References

  1. at the time of writing this
  2. i386 packages - there are also 142 64 bit packages and some 3rd party repositories

Links

  • A highly recommended read: "In the Beginning was the Command Line" by [Neal Stephenson] 7
  • Reddit [/r/bash] 8 and [/r/commandline] 9 have gems sometimes
  • [#bash on IRC] 10 has always around 1000 people online
  • [explainshell.com] 11 explains commands in a very well designed UI
  • [commandlinefu.com] 12 PORN!!!
  • stackoverflow.com [bash] 15 and [command line] 16
  • eight terminal utilities every os x [command line user] 18 should know
  • [datasets to play with] 24
# Let's grab some data from the US Census Bureau. How about names?
# It would be interesting to run some comparisons between the data from
# 1990 and 2000, but unfortunately we deal with a government managed resource
# so we have inconsistencies in the file formats etc. Nothing we couldn't solve
# with some more scripting. But also a good example of why we're screwed trusting
# these people with the management of our countries.
# For explanation of the data format see:
# http://www.census.gov/genealogy/www/data/1990surnames/names_files.html
# More data to play with:
# http://www.ssa.gov/OACT/babynames/limits.html
# http://www.outpost9.com/files/WordLists.html
# http://www.infochimps.com/datasets/word-list-21000-common-given-names-us-great-britain
# http://webdocs.cs.ualberta.ca/~bergsma/Gender/
http://www.census.gov/genealogy/www/data/1990surnames/dist.female.first
http://www.census.gov/genealogy/www/data/1990surnames/dist.male.first
http://www.census.gov/genealogy/www/data/1990surnames/dist.all.last
# playing with the data? just wget it for a local copy or pipe it into the shell
# with curl for further processing. example:
curl http://www.census.gov/genealogy/www/data/1990surnames/dist.female.first | \
awk '{print $1}'
# Let's play with some text.
# http://introcs.cs.princeton.edu/java/data/dickens.txt
# http://www.gutenberg.org/cache/epub/2701/pg2701.txt
# http://hci.stanford.edu/jheer/workshop/data/crime/CrimeStatebyState.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment