Archives for Rediscovering Unix

Rediscovering Unix and Unix Scripting After a Few Years Off

Using Escape Codes and Setting Window Title on PS1 for ksh (Korn Shell)

I set up the following in my ~/.profile for my ksh login: export HOST=$(hostname)   export PS1=$(perl -e ‘printf "\033]0;\${USER}@\${HOST}:\${PWD}\007\$"’) Unfortunately, ksh doesn’t understand escape codes, so perl or awk is necessary to pull this off–or you can enter them literally via your editor. I like the perl route just for ease of maintenance. This [...]

Date formatting for Single Unix Specification(R) versions of “date”

The date command is wonderful for formatting dates, as such date –date="2010-01-01" +%Y%j But what happens when you’re on a system whose date command only supports the -u [UTC] and + [for formatting] options? Below is a quick hack in straight C that provides the ability to format a date that you provide. This is [...]

Perl Documentation Bookmarklets

Below are some bookmarklets to quick link to CPAN documentation… Click and drag the links to your bookmark bar or use the included source code to create the bookmarklets. They will generate a prompt something like this when clicked: Bookmarklet to search for a keyword in CPAN documentation: Search CPAN Source: 1 javascript:{x=prompt("Search%20for%20module");window.location=’http://search.cpan.org/search?mode=module;query=’+x;} Bookmarklet to [...]

Formatting a Julian Date [Julian Day / Day of Year] in Unix

This is one of those commands that’s so simple once you recall it that you’ll smack yourself for not knowing it. If you’re ever in doubt, man date. # displays the 2-digit year + day of the year, Jan 14, 2011 = “11014″ date +%y%j # sets filename to MyFilename + 2-digit year + day [...]