In this episode, Jay McGavren shares some of his favorite tricks for working in the shell. No unreadable sed or awk scripts here. Just simple, solid tips you can use every day, including time savers with find, less, ssh, and command-line Ruby.
http://programmer.97things.oreilly.com/wiki/index.php/The_Unix_Tools_Are_Your_Friends
$ find myproject -name ".svn" -exec rm -rf "{}" \;
The exec option is particularly useful in combination with these commands:
- cat (Use with -print if you want the file name as well)
- grep --with-filename
- rm (For pete's sake, use -print to see what files get found first!)
The default prompt shows only the current file name:
...
tellus. Sed eget metus. Donec sapien justo, varius at, adipiscing quis, euismod
sed, orci. Quisque vel pede non dui adipiscing ullamcorper. Nulla facilisi.
Fusce sapien.
You can permanently set the -P option via the $LESS environment variable for a more informative prompt:
$ export LESS='-P%f (%i/%m) Line %lt/%L'
...
tellus. Sed eget metus. Donec sapien justo, varius at, adipiscing quis, euismod
sed, orci. Quisque vel pede non dui adipiscing ullamcorper. Nulla facilisi.
Fusce sapien.
TODO: brew install?
- Host: shortcut
- HostName: full address
- User: username to use
- piping back to local command
My interface to pbcopy/pbpaste/xclip/xclip -o
STDIN is tty?
DATA.readlines.map{|l| l.chomp}.each do |line|
end
__END__
$ ruby -e "f = File.open(ARGV[0]); while line = f.gets;\
print line.chomp; end" email.txt
$ ruby -e "while line = gets; print line.chomp; end" email.txt
$ ruby -ne "print chomp" email.txt
$ ruby -pe "chomp" email.txt
$ ruby -pe "chomp; gsub /Java/, '.Net'" email.txt
Unix utilities: http://unixhelp.ed.ac.uk
find: http://unixhelp.ed.ac.uk/CGI/man-cgi?find cat: http://unixhelp.ed.ac.uk/CGI/man-cgi?cat grep: http://unixhelp.ed.ac.uk/CGI/man-cgi?grep rm: http://unixhelp.ed.ac.uk/CGI/man-cgi?rm less: http://unixhelp.ed.ac.uk/CGI/man-cgi?less
Ack: http://betterthangrep.com/
Why Unix: http://programmer.97things.oreilly.com/wiki/index.php/The_Unix_Tools_Are_Your_Friends
Cygwin: http://www.cygwin.com/
Rails Installer: http://railsinstaller.org/
cb clipboard utility: https://github.com/jaymcgavren/dotfiles/blob/master/bin/cb