A selection of Nick's scripts

Most of these scripts work just fine on most UNIX flavors, including Apple's OS X. They were developed and tested mainly under linux, with not-too-old versions of perl and python. Most scripts provide help and list their available options when invoked with the -h option. None of them is especially smart (and, by sufficiently bad abuse, most of them can corrupt/destroy your data...), but a few friends and students find them useful.

Physics-oriented scripts

Data-oriented scripts

Tools to analyze/manipulate .xyz files

File/shell-oriented scripts

Latex-oriented scripts

Students should also check useful instructions on how to produce good hypertextual pdf and how to generate valid pdf/a with LaTeX. A quick look at some Common Errors in Technical Writing also helps.

Pictures/photography-oriented scripts

Instructions for unix newbies

To use these scripts...
  1. fire up a command-line terminal;
  2. create the appropriate folder [mkdir $HOME/bin] (in case it already exist, no worry, you get an error message, but can do no harm);
  3. save the script "scriptname" in there, or save it wherever your browser wants and then move it in there, e.g. [mv ~/Downloads/scriptname ~/bin]. NB! never use cut&paste from the browser screen to download any script: use the browser "Save As" function under "File"!
  4. let your computer know it is executable [chmod +x ~/bin/scriptname].

After your log out and log back in "scriptname" should become a legitimate command, exactly like ls or cp, and it should run regardless of the folder you are working in.
If it does not work, most likely your path needs fixing, typically by adding a line of instructions to your ~/.bashrc file. The simplest way to add this instruction is executing the command echo '\nPATH=$HOME/bin:$PATH' >> $HOME/.bashrc . (Please execute this command once only: repeated executions of this line produce a dumb sequence of contradictory lines at the end of "$HOME/.bashrc". In case you accidentally created them, please edit that file and delete all but one line PATH=$HOME/bin:$PATH.) After your next login your "scriptname" should execute fine from the command line.

Whenever it makes sense, these scripts throw their output to stdout, i.e. output appears in the terminal window. Their normal use is therefore
scriptname [options] inputfile [moreinputfiles] > outputfile
For example:
prunedata file_to_be_pruned.dat > pruned_file.dat

In case you forgot to redirect output with > and your terminal happens to be scrolling zillions of lines, then maybe you'd better press CTRL-C to kill execution, and repeat your command line with an appropriate redirection.

Most script honor the -h option, which lists accepted command-line options.

A note on redirecting output: command > somefile replaces whatever content was in somefile with the output of command. This may lead to the unwarned irreversible destruction of potentially precious data. If this makes you feel unsafe (it should!), then

  1. backup regularly,
  2. test scripts in folders where you keep no precious unduplicated data, and
  3. think twice before pressing enter!

Comments / debugging / patches are welcome!

<separation line>
created: 23 Aug 2002
last modified: 10 May 2019
by Nicola Manini