Thursday, 19 February, 2015
Google Montreal
Shopify Montreal
LinuxCommand.org
You have Linux installed and running. The GUI is working fine, but you are getting tired of changing your desktop themes. You keep seeing this "terminal" thing.
A command-line interface (CLI) is a means of interacting with a computer program where the user issues commands to the program in the form of successive lines of text (command lines). https://en.wikipedia.org/wiki/Command-line_interfaceSpecifically, the computer program is the operating system (UNIX or nowadays Linux) and the interface is what we called the
shell
.
The Unix philosophy of simple tools, each doing one job well, then cleverly piped together, is embodied by the command line. Jeroen expertly discusses how to bring that philosophy into your work in data science, illustrating how the command line is not only the world of file input/ output, but also the world of data manipulation, exploration, and even modeling.
for i in *pdf; do evince $i; done
In a script
for i in *pdf
do
evince $i
done
or even
for i in `ls *pdf`
do
evince $i
done
cli-talk: $ [ -f index.html ] && echo "Yes, we have a presentation!" \
|| echo "PANIC"
cli-talk: $ locate *9768.JPG
Strictly speaking, there are neither regular expressions nor
patterns used in pattern recognition.
They are
glob patterns
.
ls app/*.{erb,scss,rb,yml}
vi public_html/[iI]*.htm*
my_dir
.
mv {IMG,img}*201[012]*.{jpg,JPG,png,gif} my_dir
locate
versus find
LoriBiz: $ locate *.erb
LoriBiz: $ find . -name *.erb
find . -name *.erb -exec ls {} \;
find . -name *.erb -exec grep mytableauthor {} \;
find . -name *.erb -exec grep -H mytableauthor {} \;
find . -name *.scss -exec grep -H mytableauthor {} \;
find . -name *.scss -exec grep -n -H mytableauthor {} \;
cli-talk $ grep "\s\+$" index.html
LoriBiz$ find . -name *.erb -exec grep -Hn "\s\+$" {} \;
LoriBiz$ find . -name *.erb -exec grep -Hn "\s\+$" {} \; -exec vi {} \;
# Once in vi find and replace using the command
:%s/\s\+$//
superspreadsheet.wordpress.com
pull
from the bare repositorycommit
local changespush
changes to the bare repository
1 #!/bin/sh
2 #
3 # Automatic pull and commit on the directories listed in dirs_to_pull
4
5 CRONLOG="/complete/path/to/pullcommitpush.log"
6 COMMITMSG="/complete/path/to/msgAutoCommit"
7 echo >> $CRONLOG
8 echo "Nightly git auto-commit for the absent minds: $(date)" >> $CRONLOG
9 for i in `cat /complete/path/to/dirs_to_pull`
10 do (cd $i;
11 echo "PULL $i $(date)" >> $CRONLOG ;
12 git pull >> $CRONLOG 2>&1 ;
13 echo "COMMIT $i $(date)" >> $CRONLOG ;
14 git commit -a -F $COMMITMSG >> $CRONLOG 2>&1
15 echo >> $CRONLOG )
16 done
17 echo >> $CRONLOG ;
1 #!/bin/sh
2 #
3 # Automatic push on the directories listed in dirs_to_push
4
5 CRONLOG="/complete/path/to/pullcommitpush.log"
6 echo >> $CRONLOG
7 echo "Nightly git auto-push for the absent minds: $(date)" >> $CRONLOG
8 for i in `cat /complete/path/to/dirs_to_push`
9 do (cd $i;
10 echo "PUSH: $i $(date)" >> $CRONLOG
11 git push >> $CRONLOG 2>&1
12 echo >> $CRONLOG
13 ) ;
14 done
15 echo >> $CRONLOG ;
cron
: from the Greek word for time, χρόνος chronos.
Cron is a time-based job scheduler that Sysadmins use to schedule jobs to run periodically at fixed times, dates, or intervals (i.e. download email at regular intervals).
crontab -e
minute hour dayOfMonth month dayOfWeek command
3 2 * * * /complete/path/to/pull_commit 2> /complete/path/to/pull_commit.err
5 2 * * * /complete/path/to/push 2> /complete/path/to/push.err
reveal.js
.