Archive for 'UNIX Shell'
I had to do some pattern matching last week, and needed a way to print the two lines that occurred after each line that matched a specific string. Since awk provides robust pattern matching, I came up with the following awk command line to grab the information I needed: $ cat test foo 1 2 [...]
While reviewing some shell scripts last week, I saw the infamous find | grep: $ /usr/bin/find /foo -type f | egrep -v \*.inp I am not real sure why more people don’t leverage the logic operations build into find: $ /usr/bin/find /foo -type f -not -name \*.inp This saves a fork() and exec(), and should [...]
I periodically need to format text data on my Linux desktop for printing, and have always gone about this in one of two ways. If I want to add margins and make the data conform to a specific page length, I use the pr utility. Here is an example that formats FILE with a #4 [...]
I use bash as my primary shell, and have come to rely on the following bash short cuts: alt-f — move forward one word alt-b — move backwards one word ctrl-a — takes you to the begining of the command you are currently typing. ctrl-b — move backwards one character ctrl-c — kills the current [...]
GNU date has some nifty options, and is a time keepers toolbox rolled up into an ELF executable. One really cool option in GNU date is the ability to print a date in the past using the the “–date” option, and the “days ago” format string: $ date –date=”30 days ago” Wed Aug 30 15:15:51 [...]
Bash is a great shell, and has numerous capabiltiies to make peoples life easier. One super nifty feature is the ability to search through the shell’s history by hitting cntrl-r (control then the letter ‘r’): $ cntrl-r (reverse-i-search)`meta’: metastat Once you locate the command you want to run, you simply hit enter to execute it. [...]