Bash
Printing And Counting
PRINTING
echo "Hello, World!"
Prints Hello, World! to your screen.
cat some_data.csv
Prints the entire contents of the some_data.csv file to your screen.
head some_data.csv
Prints the first ten rows of the some_data.csv file to your screen.
head -50 some_data.csv
Prints the first fifty rows of the some_data.csv file to your screen.
tail some_data.csv
Prints the last ten rows of the some_data.csv file to your screen.
tail -50 some_data.csv
Prints the last fifty rows of the some_data.csv file to your screen.
COUNTING
wc some_data.csv
Counts the number of lines, words and characters in some_data.csv - and prints this information to the screen.
wc -l some_data.csv
Counts only the number of lines in some_data.csv. (Note: -l stands for line.)
wc -w some_data.csv
Counts only the number of words in some_data.csv. (Note: -w stands for word.)
wc -c some_data.csv
Counts only the number of characters in some_data.csv.
PRINTING TO FILE
In complex data projects, you don't want to print results to your terminal screen. You want to save them into files, so you can reuse them later.
e.g.:
head some_data.csv > first_ten_rows.csv
Takes the first ten rows of the some_data.csv file and prints them into the file
called first_ten_rows.csv. (If the first_ten_rows.csv file didn't exist before, it will be
created. If it did exist, then it will be overwritten.)
head some_data.csv >> some_rows.csv
Takes the first ten rows of the some_data.csv file and adds them to the end of the
file called some_rows.csv. (If the some_rows.csv file didn't exist before, it will be
created. If it did exist, then the new lines will be appended to the file after the
already-existing lines.)