Skip to content

Instantly share code, notes, and snippets.

@slwu89
Last active August 27, 2017 18:54
Show Gist options
  • Save slwu89/407c0028a4a6651915bf283898e33c82 to your computer and use it in GitHub Desktop.
Save slwu89/407c0028a4a6651915bf283898e33c82 to your computer and use it in GitHub Desktop.
stat243-bash
1. mypython=$(which python)
2. myvar=$(hostname)@$(whoami)
3. mkdir -p temp/proj{1..3}/{code,data}
4. wc -l FILE
5.
#first 3 lines in file
head -n 3 FILE
#3rd line in file
sed -n '3p' FILE
6. sed -n '3p' FILE >> NEWFILE
7. sed -n '5p' FILE >> NEWFILE
8.
# download data
curl https://raw.githubusercontent.com/berkeley-scf/tutorial-using-bash/master/cpds.csv > cpds.csv
# take out australia
awk -F "\"*,\"*" '$2=="Australia" {print $0}' cpds.csv >> cpds_australia.csv
9. grep -v "," FILE
10.
#!/bin/bash
touch file{1..3}.txt
echo blah | tee file{1..3}.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment