A list of some of my favorite unix commandsIf this page is interesting, you may also want to see my Mac commands page sudo /etc/init.d/vpnclient_init start initialize the vpnclient service sudo vpnclient connect cuboulder connect to CU's VPN service from off-campus sudo vpnclient connect oncampus connect to CU's VPN service from on-campus ls --color=never | grep "old" | xargs -n1 rm remove a list of files (in this case, list containing the string old cat 2007-11-12T23\:53\:40.log | grep TEMP= | sed -e 's/.*TEMP=//' -e 's/,/ /g' -e "s/'//" > log_to_plot.txt NICFPS log file parsing to send to gnuplot echo "plot [][] 'plotfile.tsv' index 0 using 1:($2-$3)" | gnuplot -persist Plot the contents of a file using gnuplot Image resize / thumbnail creation using imagemagick's convert commandls *.gif | sed 's/\(.*\).gif/\/sw\/bin\/convert \1.gif -resize 100x100 thumbs\/\1_tn.gif/' | bash using imagemagick's convert to create thumbnails ls *.png | sed 's:\(.*\).png:/sw/bin/convert \1.png -resize 100x100 thumbs/\1_tn.png:' | bash using imagemagick's convert to create thumbnails (full path) ls *.png | sed 's:\(.*\).png:/sw/bin/convert \1.png -resize 800x800 ../\1.png:' | bash using imagemagick's convert to create smaller images ls *.jpg | sed 's:\(.*\).jpg:/sw/bin/convert \1.jpg -resize 100x100 thumbs/\1_tn.jpg:' | bash jpg thumbnails pstoimg -type png -crop a -density 600 *.ps using latex2html cat trackdb.121207.txt | grep google | grep search | sed -e "s/.*[?\&\_]q=\(.*\?\)\&.*/\1/" | less Search my tracker for hits from Google so I can see what search terms have been used to find this site IRAF:imhead *.fits lo+ | grep -E "Pixel\ file\|EXPTIME" find exposure times and file name for all fits files using IRAF's imheadecho "from pyraf import iraf; s=iraf.imhead('*.fits',long='yes',Stdout=1); iraf.grep('-E EXPTIME\|Pixel\ file',Stdin=s)" | python same using pyraf from command line Python:numarray.concatenate = numpy.hstack (numpy.concatenate is not equivalent to numarray.concatenate, it does not accept scalars)glob.glob(filename) filename retrieval with wildcards "Grep" type search with Python: Python lacks a simple "grep" command to scan a list; I've written one for i in dir(): print "%s: %s" % (i,eval(i)) a useful quick look at all the variables available (particularly useful when using pdb, the interactive debugger VIM:There are some tasks too complicated for vim's internal substitution commands%!perl -pe 's/(.*AREA HEIGHT.*WIDTH=")([0-9\.]*)(.*)/$1.($2+120).$3/e' is a complicated statement: it replaces a number that occurs after WIDTH= with that number + 120. The line number to operate on must be specified, even if it is global (% or g//). Dots connect the output statements within the perl replacement side. /e evaluates the replacement side rather than just printing it. The parentheses are required. %!awk '{print "point("$2":"$3":"$4","$5":"$6":"$7") \# point=arrow text={"$1"}"}' Reformat catalog as DS9 region file %!awk 'BEGIN {FS="|"} {print $5" "$3}' %!awk '{print "point("$1":"$2":"$3","$4":"$5":"$6") \# text={"$7" "$8" "$9" "$10" "$11" "$12"}"}' SIMBAD catalog to ds9 regions file (requires significant filtering because SIMBAD is inconsistent between lines) s/(.\{-})// is the non-greedy version of s/(.*)// '<,'>s/\(.*\)\.\(.*\)\(.png\)/<h3>\2</h3>\r<img src="images\/orion\/thumbs\/\1.\2_tn.png" \ronclick="toggle('\1','images\/orion\/thumbs\/\1_tn.png','images\/orion\/\1.png')" \rname="\1"> %s/<a href="images\/\(.*\)\(...g\)"><img src="\(.*\)"><\/a>/<img src="\3" onclick="toggle('\1','\3','images\/\1\2')" name="\1">/ %s/\(.*\)\(.jpg\)/<img src="images\/jcmt\/thumbs\/\1_tn.jpg" onclick="toggle('\1','images\/jcmt\/thumbs\/\1_tn.jpg','images\/jcmt\/\1.jpg')" name="\1">/ '<,'>s/\(.*\)\(.jpg\)/<img src="images\/jcmt\/thumbs\/\1_tn.jpg" \r\tonclick="toggle('\1','\1_tn.jpg','\1.jpg')" \r\tname="\1">/ %!awk '{print "union select s.*,n"NR".universalid as n"NR"universalid from sagecatalog as s, fGetNearbyObjEqUTC("$1","$2".02 as n"NR" where n"NR".universalid=s.universalid and s.epoch="}' 5,30!awk 'BEGIN {OFS=""} {a = substr($0,12,2); print substr($0,0,11) , ":" , sprintf("\%2.2d",a*60.) , substr($0,14,100)}' arithmetic operations using AWK instead of SED (useful when a catalog outputs decimal arcminute units when you want arcseconds) ESSENTIAL: if backspace in insert mode fails, you must :set bs=2. VIM becomes VI - and, imo, generally unusable - without this. Apache Server:/etc/init.d/apache2 start Initiate daemon/etc/apache2/apache2.conf Configuration file (can use ln -s to link a new home directory to your default /var/www) The .htaccess file allows you to modify the way files are processed in a given directory. Apache server in Ubuntu More to come, but in the meantime these pages are recommended: Pat Hartigan's Computer Page Anyone who has attempted to install a unix system should be familiar with this Perlperl -ne 'if (/RA/ && /DEC/) {$_ =~ m/RA *= .([0-9:\.]*)/; print $1,"\t"; $_ =~ m/DEC *= .([0-9:\.-]*)/; print $1,"\n";'} a hideously ugly and relatively slow way to extract RA and DEC from fits files. Does NOT print the file name |