Changes

Home

3,252 bytes removed, 16:59, 16 May 2012
no edit summary
[[Classes]]
 
[[Projects]]
 
[[Teaching]]
 
[[Video Tools]]
[[Linux Commandline Stuff]]
== Teaching Resources ==
[[Classes]]
== Linux Commandline Stuff ==
=== remove page numbers in place with perl ===
 
<code> perl -pi -e "s/p+\s+\d+(-\d*)*\.|p+\d+(-\d*)*\.//g" reading.txt </code>
 
=== rsync to transfer files to server ===
*local current directory to home/pictures directory:
<code>rsync -avz --stats --progress Pictures roberttwomey.com:~/pictures/</code>
*local directory to current directory:
<code>rsync -avz --stats --progress /Volumes/BOOTCAMP/Users/rtwomey/Documents/ .</code>
*local directory to server backup:
<code>rsync -h -e ssh -avz --stats --progress ./Movies/* b393466@hanjin.dreamhost.com:~/Movies/</code>
 
<code>rsync -e ssh -avz --stats --progress ./Documents USER@SERVER.dreamhost.com:~/</code>
*server backup to local directory:
<code>rsync -e ssh -avz --stats --progress USER@SERVER.dreamhost.com:~/Documents .</code>
*grab documents from online backup:
<code>rsync -n -h -e ssh -avz --stats --progress b393466@hanjin.dreamhost.com:~/Documents/dxarts473_s11/ Documents/</code>
==== rsync push.sh ====
with optional delete
<pre>
#!/bin/bash
 
echo name of script is $0
echo first argument is $1
 
if [ $# -lt 1 ]
then
echo "usage: $0 [DIRECTORY]"
echo " or"
echo " $0 -n [DIRECTORY]"
echo " or "
echo " $0 -n --delete [DIRECTORY]"
exit
fi
 
 
if [ $1 = "-n" ]
then
if [ $2 = "--delete" ]
then
cmd="rsync -n --delete -h -e ssh -avz --stats --progress $3 b393466@hanjin.dreamhost.com:~/$3"
else
cmd="rsync -n -h -e ssh -avz --stats --progress $2 b393466@hanjin.dreamhost.com:~/$2"
fi
elif [ $1 = "--delete" ]
then
cmd="rsync --delete -h -e ssh -avz --stats --progress $2 b393466@hanjin.dreamhost.com:~/$2"
else
cmd="rsync -h -e ssh -avz --stats --progress $1 b393466@hanjin.dreamhost.com:~/$1"
fi
 
echo $cmd
$cmd
</pre>
 
==== rsync pull.sh ====
 
<pre>
#!/bin/bash
 
echo name of script is $0
echo first argument is $1
 
if [ $# -lt 1 ]
then
echo "usage: $0 [DIRECTORY]"
echo " or"
echo " $0 -n [DIRECTORY]"
echo " or "
echo " $0 -n --delete [DIRECTORY]"
exit
fi
 
if [ $1 = "-n" ]
then
if [ $2 = "--delete" ]
then
cmd="rsync -n --delete -h -e ssh -avz --stats --progress b393466@hanjin.dreamhost.com:~/$3 $3"
else
cmd="rsync -n -h -e ssh -avz --stats --progress b393466@hanjin.dreamhost.com:~/$2 $2"
fi
elif [ $1 = "--delete" ]
then
cmd="rsync --delete -h -e ssh -avz --stats --progress b393466@hanjin.dreamhost.com:~/$2 $2"
else
cmd="rsync -h -e ssh -avz --stats --progress b393466@hanjin.dreamhost.com:~/$1 $1"
fi
 
echo $cmd
$cmd
</pre>
 
=== finding things with ls and grep ===
* find this filename in a recursive search and show previous 30 lines of result:
<code>ls -laR . | grep -b30 "scale_signal.o" </code>
 
=== forwarding localhost mysql to a remote machine ===
* do this to connect to 192.168.0.39 for instance:
<code>ssh -f -L 3306:localhost:3306 rtwomey@192.168.0.39 sleep 10</code>
*tunnelMySql.sh:
<code>
 
ssh -fNg -L 3306:localhost:3306 rtwomey@192.168.1.191
</code>
=== grabbing a website with wget ===
*grab a website recursively
<code> wget -r --level=1 http://www.ppc.sas.upenn.edu/ppquestionnaires.htm </code>
== GCC Stuff ==