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
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 [...]
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 [...]
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 [...]
Sometimes simply checking the size of the whole directory is not enough, and you need more information, e.g. the whole directory has 3GB – but how much of it are those .avi files inside? The most flexible way for matching the files (or directories) is by using find command, so let’s build the solution based [...]
Say you would like to transfer set of files from location A to B. The source directory is really big but you are only interested in transferring some files (say *.png only). rsync is a good tool for the job. There are two methods I know that can be utilized. find + rsync Use find [...]
Normally when you quit less, your screen will be redrawn and you will be back with the content you could see on your screen before using less. Sometimes though it’s very handy to see the file with less, scroll down to the fragment of your interest and have that fragment still visible on the screen [...]