Thursday, 11 August 2011

Recursive find

Sometimes you don't have locate , or you want just to find recursively below your current directory. Here is a handy alias:

alias fn='find . -name':
Example usage: $ fn "page*.htm"

Tip from Joe Grossberg.

Sunday, 10 April 2011

Encode video FLV to AVI with one line

Just found on the Ubuntu forums a way to convert FLVs to AVI with a single shell line, using mencoder:

for file in *.flv; do mencoder -oac mp3lame -ovc lavc "$file" -o "`echo $file | sed -e 's/\.flv$/\.avi/'`"; done

Source is this thread.
However with gnome-mplayer it seems I can't always navigate the resulting AVI.

Friday, 18 February 2011

OCR of scanned PDFs in Linux

It seems there is still no quick-and-ready solution, but found a few interesting scripts.

This script based on Tesseract worked well for me. It requires to have Tesseract and ghostscript installed, and returns a number of ASCII text files from the PDF. Given that the OCR engine is the same used by Google, you can be assured it works pretty well.

A bit less comfy solution can be found on this Linux.com article, with some shell script based on Tesseract as well.

Another solution using other engines.

It seems also there is a potentially elegant GUI solution by means of OCRFeeder, but I still haven't tried it. I'll let you know how it works, for now I just bookmark these links.

Tuesday, 8 February 2011

Install True Type fonts on Ubuntu in three steps

It's very easy:

1)Create a .fonts subdirectory in your home directory
cd ~
mkdir .fonts

2)Move the .ttf file in the .fonts directory
mv myfont.ttf ~/.fonts

3)Refresh the font cache
sudo fc-cache -f -v

And your font should be ready to be used.
Credits to Detector Pro -I streamlined the process a bit, being comfortable with the command line.

Wednesday, 26 January 2011

How to symlink all files in a directory

It seems that a simple ln -s /dir/* doesn't work, so:

for f in $(ls -d /base/*); do ln -s $f /target; done && ls -al /target



From commandlinefu.com

Saturday, 8 May 2010

udevinfo and udevadm

If you have ever tried to write UDEV rules , say, to get your external hard drive to mount at your preferred custom mount point, you will have found necessary to use the little utility udevinfo.

Recently this utility has been superseded by udevadm. However there is a way to get the old udevinfo output back with udevadm:

udevadm info -a -p $(udevadm info -q path -n /dev/your-device)

and you will have the same output you would have had with udevinfo. Very useful! Credits to Unlikely Source for the hack.

Sunday, 25 May 2008

Where is my GRUB?

On the Gentoo mailing list, a nice thread evolved a way to find where did you install your bootloader last time. The question is less trivial than it seems - is it on your disk MBR or on your partition? If you have a non-obvious setup, you may forget... and if you try to upgrade/reinstall GRUB without remembering where it is, bad things can happen.

The solution is:
for i in /dev/[hs]d*
dd if=$i bs=446 count=1 2>/dev/null | strings | grep -q GRUB \
&& echo "GRUB found in $i"