Last active
August 28, 2017 23:41
-
-
Save slwu89/786c562e39d06be056ce9415b9469581 to your computer and use it in GitHub Desktop.
stat243-week2lecture1.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################################ | |
# Lecture | |
################################################################################ | |
# BASH stuff: | |
ls -tr *.R # gives you the list of the R files modified most recently (closest in time at bottom, farthest in time at top) | |
ls -tr *.R | tail - n 5 # last five things modified | |
ls -tr *.R | tail - n 5 | grep optim # look for files called 'optim' in the name | |
grep 'example.pdf' $(ls -tr *.R) # look for example.pdf in the stuff from inside $(.) | |
# xargs prepends a function and inserts the piped stuff into the argument part of the function | |
# note that the . here is searching for the wildcard regex . not the explicit . which would be /. (i think) | |
ls -tr *.R | tail -n 5 | xargs grep -l 'example.pdf' | |
# Jared note | |
grep -r #r flag: searches recursively in subdirs that you feed it, even inside of text files! | |
grep -F #F flag: fixed string, no regex | |
grep -c #c flag: gives count of how many instances it gives | |
# file globbing: if you want to find all .R ext files but with some basic regex-y things with it: | |
ls unit[1-9]*.R | |
# | |
grep --no-filename "^library" *.R | |
# using sed to handle stuff inside of R scripts/general files | |
sed 's/;\n/g' # replace every instance of first thing with newline globally | |
# controlling jobs on a unix machine | |
# how to query and look for particular types of jobs (given by 'top') | |
ps -o #o flag: you can tell what columns you want to outpu | |
ps -o pid,pcpu,pmem,user,cmd | |
ps -o start_time --sort=start_time -C R # get R jobs started recently. | |
# xargs: pass arguments, not stdin to the function put right after it. | |
################################################################################ | |
# Discussion | |
################################################################################ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment