To make star character in bash to match hidden files, use dotglob option: $ shopt -s dotglob If directory contains both normal and hidden (.*) files, here what you will get without and with dotglob set: $ ls * file1.txt file2.txt $ shopt -s dotglob $ ls * file1.txt file2.txt .htaccess .htpassword
I find this one very useful, when you press just CTRL-G in vim you will get some basic file information: "abc.tmp" 165 lines –36%– When you use put count (a number) 1 before that command, the path will get expanded to full path (but shortened with ~ for the home directory). So when pressed: 1 [...]
Thursday, December 29, 2011
I wanted to iterate over set of directories and calculate total number of files inside each of them (recursively). xargs & find would do it just fine but you can not easily escape pipe inside xargs command. Here is the solution: ls | xargs -n1 -I{} sh -c ‘echo -n "{} "; find {} -type [...]
Saturday, December 17, 2011
I usually set my postfix to relay via gmail SMTP to allow me for reliable external email delivery from my gmail address, with the convenience of the command-line. To send an email using mail utility I can simply use: $ cat email.txt | mail email@example.com This will generate an email with default X-Mailer tag, like: [...]
Here is the error from dmesg I’ve got when trying to mount external HDD: [345826.197335] EXT3-fs error (device sdd1): ext3_check_descriptors: Block bitmap for group 1920 not in group (block 0)! [345826.198130] EXT3-fs (sdd1): error: group descriptors corrupted Trying to mount as ext2 didn’t change anything: [346348.544459] EXT2-fs (sdd1): error: ext2_check_descriptors: Block bitmap for group 1920 [...]
Saturday, August 20, 2011
Here is the command: find . -type f -printf ‘%TY-%Tm-%Td %TT %p\n’ | sort -r | head
Introduction I have a collection of 160 photos that I would like to montage into a movie. Each photo was done on a different day and the brightness of each photo varies. This will definitely not look good on the photo, so I’ve decided to “normalize” the brightness across the images. That is: Find a [...]
Recently I had to locate the widest image in the set of photos in a directory. Here is how you can easily do it with identify command, from ImageMagick suit: % identify -format ‘%w %f\n’ * | sort -rn | head -n1 563 2010.12.30.JPG You can see in the output that the widest image is [...]
mogrify is the tool you are looking for – it comes with the great imagemagick package and it’s designed especially to be used for bulk operations. To resize all images in current directory to 600 pixels wide (width): % mogrify -resize 600 * The same but 600 height: % mogrify -resize x600 *
I have a collection of related photos stored on my PC. Their filenames are “ugly” – standard namings coming from the photo camera. I would like to rename them into a file containing the date when the photo was shoot, e.g. 2011.07.21.jpg. There is an excellent commandline tool to do just that – renrot. It’s [...]