Skip to main content

Posts

Showing posts with the label bash

Emptying an entire CVS directory tree

Another one on CVS. Keeping old projects in which one would spend so much effort to do a full migration to another version control system than just learn to live with the CVS limitations makes you find some weird workarounds... In CVS you can't rename a directory, you can't either remove a directory. Instead, you can remove all files in the directory tree you want to remove, and do a "CVS update -P" pruning empty directories. So, how to easily empty an entire directory tree? The find has a "-not" operator which lets you make an inverse logic. For example, you can find -name CVS to locate the CVS control directories and find -not -name CVS to find files other than the CVS control directories. Finally, to empty an entire directory, but not touching the CVS control files and folders, one could run the following line: find . -not -name CVS -a -not -name Entries -a -not -name Root -a -not -name Repository -not -type d | xargs rm; cvs remove

More trickery with gnuplot dumb terminal

In my post " Plotting memory usage on console " the chart doesn't pan the data. Now, using a named pipe, the effect got a little bit nicer. First, we have to run the memUsage.sh script to get a file filled with memory usage info: ./memUsage.sh > memUsage.dat & Then we have to create a named pipe: mkfifo pipe Now we have to run another process to tail only the last 64 lines from the memUsage.dat while [ 1 ]; do tail -64 memUsage.dat> pipe; done & And now we just have to plot the data from the pipe: watch -n 1 'gnuplot -e "set terminal dumb;p \"pipe\" with lines"' And that is it!

Plotting memory usage on console

This is just a simple hack to play around with gnuplot set to dumb terminal (character console), doesn't meant to be serious application. First I had written a bash scritp to log memory usage a while ago: So, while running this script in background ( ./memUsage.sh > memUsage.dat & ), logging the data, the memory usage information can be plotted with gnuplot and watched in real time: watch -n 1 'gnuplot -e "set terminal dumb;p \"memUsage.dat\" with impulses"' The chart can be plotted with lines, with impulses or any gnuplot style option .

Converting charset enconding of a bunch o .tex files

A friend of mine came to me asking for a simple way to convert the charset encoding of a bunch o LaTeX files. He had all his files in the UFT-8 encoding and he wanted to convert all of them to "latin-1" (ISO-8859-1). So, I saved all the files he sent me in the same folder, opened a terminal shell window and typed the following command line: ls -1 *.tex | while read line ; do iconv -f utf-8 -t iso-8859-1 $line -o "latin1_"$line; done And voilĂ  , they were now encoded with ISO-8859-1.