If PDF documents show up funny within Preview, particularly if the fonts appear wrong, there is a simple fix. Open up a Terminal window and type
killall -u <username> ATSServer
Restart Preview and the problem should be fixed.
If PDF documents show up funny within Preview, particularly if the fonts appear wrong, there is a simple fix. Open up a Terminal window and type
killall -u <username> ATSServer
Restart Preview and the problem should be fixed.
Awk makes computing the average of a column of numbers in a text file very easy. Here’s the command for computing the average of the 5th column in a text file:
cat my_file.txt | awk '{sum=sum+$5}END{print sum/NR}'
The $5 means the 5th column and the NR means the number of entries (rows) in the column.
The ‘cut’ utility on Linux/Unix is useful for selecting columns from a delimited text file. It’s basic usage is
cat my_file.txt | cut -d ' ' -f 2
This will select the second column from a space-delimited file. The -d option specifies the delimiter (default is tab) and the -f option specifies a comma-separated list of columns that you want to select from the file.
To remove CVS files from a module you have checked out from a CVS repository, you can use a simple one-line command:
find -type d -wholename '*CVS' | xargs /bin/rm -rf
Execute this from the root of the CVS module that you checked out and want to clean up.
ImageMagick’s ‘convert’ program makes it easy to stitch together two separate images so that they appear side-by-side in another image. This can be very useful for making demo videos. The command is simple:
convert image1.png image2.png +append output.png
That’s it. The command assumes image1.png and image2.png are the same height.
To apply this command to a sequence of images and get a sequence back, it does not work to do the following:
convert image1*.png image2*.png +append output.png
This actually appends all the specified images into a single frame. Instead, you can write a simple shell script to run the command many times. This one runs in bash:
n=0; while [ $n -lt 180 ]; do printf -v file1 "ModelResized/spindle-model%04d.png" "$n"; printf -v file2 "Simulation/spindle-sim%04dG.png" "$n"; printf -v outFile "output%04d.png" "$n"; convert $file1 $file2 +append $outFile; n=$[$n+5]; done;
It’s kind of ugly, but it works. One thing to note: printf works just like the C function printf. The -v VAR option stores the formatted string output into the variable VAR.