Difference between revisions of "Linux Commandline Stuff"
(Created page with "== 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 transfe...") |
|||
Line 1: | Line 1: | ||
+ | [[Home | <<< back to Wiki Home]] | ||
+ | |||
== Linux Commandline Stuff == | == Linux Commandline Stuff == | ||
=== remove page numbers in place with perl === | === remove page numbers in place with perl === |
Revision as of 10:00, 16 May 2012
Contents
Linux Commandline Stuff
remove page numbers in place with perl
perl -pi -e "s/p+\s+\d+(-\d*)*\.|p+\d+(-\d*)*\.//g" reading.txt
rsync to transfer files to server
- local current directory to home/pictures directory:
rsync -avz --stats --progress Pictures roberttwomey.com:~/pictures/
- local directory to current directory:
rsync -avz --stats --progress /Volumes/BOOTCAMP/Users/rtwomey/Documents/ .
- local directory to server backup:
rsync -h -e ssh -avz --stats --progress ./Movies/* b393466@hanjin.dreamhost.com:~/Movies/
rsync -e ssh -avz --stats --progress ./Documents USER@SERVER.dreamhost.com:~/
- server backup to local directory:
rsync -e ssh -avz --stats --progress USER@SERVER.dreamhost.com:~/Documents .
- grab documents from online backup:
rsync -n -h -e ssh -avz --stats --progress b393466@hanjin.dreamhost.com:~/Documents/dxarts473_s11/ Documents/
rsync push.sh
with optional delete
#!/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
rsync pull.sh
#!/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
finding things with ls and grep
- find this filename in a recursive search and show previous 30 lines of result:
ls -laR . | grep -b30 "scale_signal.o"
forwarding localhost mysql to a remote machine
- do this to connect to 192.168.0.39 for instance:
ssh -f -L 3306:localhost:3306 rtwomey@192.168.0.39 sleep 10
- tunnelMySql.sh:
ssh -fNg -L 3306:localhost:3306 rtwomey@192.168.1.191
grabbing a website with wget
- grab a website recursively
wget -r --level=1 http://www.ppc.sas.upenn.edu/ppquestionnaires.htm