# Clone this repository
cd ~
mkdir github
cd github
git clone "https://github.com/brunj7/eds214-handson-cli.git"
cd eds214-handson-cli
ls
cd _data/babynamesbystate
pwd
# List all the TXT files
ls *.TXT
# Do I have all the states?
ls *.TXT | wc -l # wait whaaaht!? you can pipe!
# Look at the files
head CA.TXT
tail CA.TXT
# Want to know the most frequent ones over all the years?
sort -k5 -n -t "," CA.TXT
# A little long, but wait remeber you can pipe things!
sort -k5 -n -t "," CA.TXT | tail
# Concatenate all the files into one master data set
touch baby_allstates.csv # create an empty file
echo "state, gender, year, firstname, count" > baby_allstates.csv # add the header to the file
cat *.TXT >> baby_allstates.csv # append the content of the files to the csv file
The Command Line Interface is powerful
A little bit of terminology
Command Line Interface (CLI)
: This is a user interface that lets you interact with a computer. It is a legacy from the early days of computers. Now a days computers have graphical user interfaces instead (MacOSX, Windows, Linux, …)Terminal
: It is a an application that lets you run a command line interface. It used to be a physical machine connected to a mainframe computerShell
: It is the program that runs the command line. There are many different shells, the most common beingbash
(Bourne Again SHell) which is installed by default in many Linux distributions
Why should I learn about bash !?
Did you know you can actually run R
from the command line:
R # (ctrl + D to get out of it)
Or an R script:
Rscript 10min-loop.R # (ctrl + C to kill the process)
And yes, you can run python
as well:
python # (ctrl + D to get out of it)
But this is for next week 🙂
Back to main Repo