Prefetch Technologies // Keeping your cache lines cozy

Archive

Posts in Shell

Deciphering shell exit codes

shellNov 20, 2008 1 min read

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: I was curious where the exit value of 146 came from, so I did a bit of digging. It turns out that when a shell exits due to an uncaught signal, the signal number is added to 128 and that is the value that is returned. So in the case above, the exit code 146 was returned. I digs me some random shell knowledge.

$ read more →

Bash's built in commands

shellJul 9, 2008 6 min

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: Some of these do have binaries within the /usr or /bin namespace, while others do not. Bash's internal built in definition of these commands is what actually gets executed…

$ read more →

Printing a set of lines after a pattern match

shellDec 3, 2007 1 min

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: I digs me some awk!

$ read more →

Quieting the shell during login sessions

shellJun 9, 2007 1 min

Most of the Solaris systems I access through an SSH shell session display a bunch of cruft (e.g., do you have mail?, etc.) when I login. To reduce the amount of chatter, I recently created a .hushlogin file in the home directory of each server I support: When this file is present, the logic in /etc/profile will limit what is displayed. Niiiiiice!

$ read more →

Not grep!

shellFeb 9, 2007 1 min

While reviewing some shell scripts last week, I saw the infamous find | grep: I am not real sure why more people don't leverage the logic operations build into find: This saves a fork() and exec(), and should be a bit faster. I am curious if folks use grep because it's easier to read, or because they don't know about the logic operations built into find. I shall need to investigate ...

$ read more →