Archive for 'UNIX Shell'

Sorting data by dates, numbers and much much more

Every year or two I try to re-read manual pages and documentation about my favorite UNIX tools (bash, awk, sed, grep, etc.). Each time I do this I pick up some cool new nugget of information, and refresh my mind on things that I may have forgot. While reading through an article on sort, I [...]

How to undelete any open, deleted file on linux / solaris

Chris Dew wrote up a neat trick on how to recover files if deleted on Linux, yet still open by a process. This works on Solaris as well.  =) $:~:uname -a SunOS somehost.com 5.10 Generic_127112-11 i86pc i386 i86pc $:~:echo “sup prefetch.net folks?” > testfile $:~:tail -f testfile & [1] 17134 $:~:rm testfile $:~:ls /proc/17134/fd/ 0  [...]

Helpful shell shortcuts

So this may be a little basic, but I find myself using these two shortcuts quite a bit while at the shell. If you ever find yourself wanting to “reuse” the last argument in a command — for example, here I move a file from one location into /var/tmp and I want to “cd” into [...]

Deciphering shell exit codes

I was recently debugging an issue with a shell script, and noticed that the shell was exiting with an exit code greater than 100 when it received a SIGTSTP signal: $ cat test #!/bin/bash sleep 60 # Window one $ ./test [1]+ Stopped ./test Home:~ matty$ echo $? 146 # Window two $ kill -18 [...]

Bash’s built in commands

If you’re a frequent user of the bash shell, I would suggest taking a peek at the GNU reference guide next time you have a chance.  There are a lot of cool built in functions/commands within bash that are pretty neat.  To get an idea of what these built in commands are: $ ps PID [...]

Printing a set of lines after a pattern match

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 [...]

« Older Entries