Not specific to this projec, but can be incredibly useful ways to maximizes your time. Mastering the command line is the best way to get things done, quick and cheaply.
Reapeat after me:
- I will write a script for any tasks I do regularly
basename -- what is the file name again? not the path, just the file name dirname -- what directory is this in? readllink -f -- what is the absolute path of this file? cat -- spit out the contents of one or more files cp -- copy file or dir scp -- copy file or dir to another machine rsync -- both the above, but so much more awesome -- rsync -av here there -- rsync -e ssh -av here user@host:there cut -- wish I could i could chop out this column in the middle here date -- would be nice if I had some way to make this log file name a little more unique echo -- System.out.println() xargs -- can be useful but doesn't respect paths with spaces. I only use it sometimes find -- find some files and potentially execute a command against them egrep -- search for text in a file or from STDIN. better than grep mkdir -- makes a dir, with -p will make parent dirs too mv -- move a file head -- spit out the first N lines of a file tail -- spit out the last N lines of a file tee -- I want to see the output of this command, but I also want to write it to a file. Oh! tee is awesome! perl -- edit a stream: cat file.txt | perl -pe 's/this/that/' -- edit a file: perl -i -pe 's/this/that/' pwd -- where am I? rm -- delete read (bash) -- I dig this out for strings with spaces. paths have spaces in them sometimes -- ls .txt | while read n; do echo "$n"; done -- find . -name ".txt" | while read n; do echo "$n"; done
export (bash) -- why can't my script find this command? i use this to debug scripts 'export > /tmp/script-env.txt'
for (bash) -- my favorite bash construct
-- for n in one two three; do echo "$n"; done
(side note, always quote your variables like "$n" vs
|basename | what is the file name again? not the path, just the file name|
|dirname | what directory is this in?|
|readllink -f | what is the absolute path of this file?|
|cat | spit out the contents of one or more files|
|cp | copy file or dir|
|scp | copy file or dir to another machine|
|rsync | both the above, but so much more awesome|
| | rsync -av here there|
| | rsync -e ssh -av here user@host:there|
|cut | wish I could i could chop out this column in the middle here|
|date | would be nice if I had some way to make this log file name a little more unique|
|echo | System.out.println()|
|xargs | can be useful but doesn't respect paths with spaces. I only use it sometimes|
|find | find some files and potentially execute a command against them|
|egrep | search for text in a file or from STDIN. better than grep|
|mkdir | makes a dir, with -p will make parent dirs too|
|mv | move a file|
|head | spit out the first N lines of a file|
|tail | spit out the last N lines of a file|
|tee | I want to see the output of this command, but I also want to write it to a file. Oh! tee is awesome!|
|perl | edit a stream: cat file.txt | perl -pe 's/this/that/'|
| | edit a file: perl -i -pe 's/this/that/'|
|pwd | where am I?|
|rm | delete|
|read (bash) | I dig this out for strings with spaces. paths have spaces in them sometimes|
| | ls .txt | while read n; do echo "$n"; done|
| | find . -name ".txt" | while read n; do echo "$n"; done|
|export (bash) | why can't my script find this command? i use this to debug scripts 'export > /tmp/script-env.txt'|
|for (bash) | my favorite bash construct|
| | for n in one two three; do echo "$n"; done|
| (side note, always quote your variables like "$n" vs
|bash | quick way to run a script if it isn't already executable| |chmod | this file should be executable| |clear | my terminal is messy| |diff/patch | comparing or merging file contents| |ps/kill | my script is running too long, i want to force it to stop| |less | paging through command line output| |nohup | I don't want this script to die if my connection is interrupted| |which | where does this command live?| |crontab | schedule something to run regularly (i use 'bash -l foo.sh' to run stuff in my crontab file)| |shutdown | shutdown or restart a machine| |top | what the heck is chewing up my cpu?| |uname | what system am I on?|
sed -- i always use "perl -pe 's/find/replace/'")