Friday, 20 April 2012

dos2unix on Mac OSX

File conversion from dos to unix files on OSX has always been a bit flaky for me. Handily the tr command in one of two variants does the job:


tr '\r' '\n' < dosfile > unixfile


tr -d '\r' < dosfile > unixfile

Tuesday, 27 March 2012

Padding for superscript and subscript axis labels in gnuplot

By default gnuplot doesn't align superscripts and subscripts:
T_c^{/Symbol \245}

But, that leaves an ugly space between the symbol and superscript. You can force alignment with an @ character:

T@_c^{/Symbol \245}
 This works fine for standard characters, but for slanted variables, the align character makes the superscript overlap. To fix this we insert a partial before the infty symbol in the superscript. To do this we combine two text effects, blank characters &{a} and font size scaling {/* }:

T@_c^{{/*0.5 &{c}}{/Symbol \245}}

To give the desired result. You can change the factor 0.5 to whatever you need, with 1.0 being full character width.

Tuesday, 20 March 2012

Bash function to wget from user space in york

This can be placed in .bashrc and can be used to get a file from (your username abc500)

http://www-users.york.ac.uk/~abc500

(this is on unix0 in the web directory.

wgetyork ()
{
if [ -f "$1" ];then
rm "$1";
fi
wget http://www-users.york.ac.uk/~abc500/"$1"
}

it checks for the file because wget will save the file you download as filename.1 if you already have a file called filename. Call it using

wgetyork filename

Thursday, 15 October 2009

cropping pdfs from terminal

From terminal you can use pdfcrop, which should be installed on most linux systems. As its terminal based it is easier to script.

example

pdfcrop --margins '5 0 5 10' --clip input.pdf output.pdf

Friday, 4 September 2009

Make tar.gz

tar czvf myarchive.tar.gz myfile

Monday, 15 June 2009

Multiple files in gnuplot

Seems obvious now but you can use paste

e.g.

plot "< paste file1.dat file2.dat" using 1:($2/$4) w points

Searching for tabs with grep

I was trying to search for an integer number, which had tabs after is
i.e grep 300 and it would come up with something like
300 -0.0137598 -0.00228325 0.930859 0.932037 -1.04561e+27 -1.73505e+26 7.07363e+28 7.08259e+28 -0.0129162 -0.00224769 0.874459 0.875568 0.00575037 0.00194563 -0.395375 0.396846 1.46282e+24
450 -0.00449249 -0.00663059 0.858427 0.869783 -3.41386e+26 -5.03861e+26 6.52322e+28 6.60951e+28 -0.00415084 -0.00613002 0.795084 0.805603 0.00124869 0.00187794 -0.257016 0.262097 1.46282e+24
etc....


i.e. where there is 300 within any number. To search for 300 i used
grep 300[[:space:]]