Technical Blog by Tomasz Muras Technical Blog
  • Search
Navigation bar avatar
✕

    Bash

    • How to wait for process to finish in bash and check its exit code?

      Posted on September 8, 2023

      We want to run some process in the background and continue script execution. Then at some point we want to stop and wait for this process to finish. We also want to capture the exit code of this process. Once we have PID of the process we put in background,… [Read More]
      Tags:
      • bash
      • linux
    • Brace expansion in bash and zsh

      Posted on October 23, 2012

      Bash and zsh both have a very neat feature for expanding a single word into more: brace expansion. For the simplest example, imagine you need to move file.old as file.new. Normally you type: [Read More]
      Tags:
      • bash
      • zsh
    • xargs, find and escaping pipe and semicolon

      Posted on 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: [Read More]
      Tags:
      • debian
      • linux
      • ubuntu
      • bash
    • Automatically equalize brightness of several images

      Posted on August 14, 2011

      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.… [Read More]
      Tags:
      • debian
      • ubuntu
      • linux
      • bash
    • How to find the widest image

      Posted on August 12, 2011

      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: [Read More]
      Tags:
      • linux
      • ubuntu
      • debian
      • bash
    • Resize images in bulk to the same width or height, same aspect

      Posted on August 9, 2011

      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): [Read More]
      Tags:
      • debian
      • linux
      • ubuntu
      • bash
    • Bulk rename photos to date

      Posted on August 4, 2011

      I have a collection of related photos stored on my PC. The filenames were “ugly” – standard file names 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… [Read More]
      Tags:
      • debian
      • linux
      • ubuntu
      • bash
    • Recursively find total size of selected files-directories

      Posted on June 28, 2011

      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… [Read More]
      Tags:
      • debian
      • linux
      • ubuntu
      • bash
    • Transfer-only-selected-file-types-with-rsync

      Posted on April 21, 2011

      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. [Read More]
      Tags:
      • bash
      • rsync
    • Quit less without cleaning the screen

      Posted on April 7, 2011

      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… [Read More]
      Tags:
      • linux
      • bash
      • shell
    • Execute a command with a timeout

      Posted on July 22, 2010

      Sometimes you need to stop a command, if it executes for too long. It’s very simple with a timeout utility from coreutils package. timeout is available in coreutils 8.X – recent enough version is currently in Debian squeeze and sid only. The version in Ubuntu 10.04 is too old (does… [Read More]
      Tags:
      • bash
      • debian
    • The power of imagemagick

      Posted on July 14, 2010

      There is probably no need for me to introduce a great library for processing images: imagemagick. In this mini how-to I will show how I’ve used imagemagick to build an image from few different pieces of media (images and text). [Read More]
      Tags:
      • debian
      • ubuntu
      • bash
    • Easy password-less SSH login

      Posted on June 4, 2010

      [Read More]
      Tags:
      • ssh
      • bash
    • Parallel downloads with wget

      Posted on May 21, 2010

      How to download a list of URLs using more than one process (say wget) at the time? First, create a file with URLs – one URL per line. Let’s call the file url.txt. Then we need to create N wget processes, each downloading one URL at the time. Thanks to xargs… [Read More]
      Tags:
      • linux
      • bash
      • wget

      Tomasz Muras  •  2026

      Powered by Hugo, styled with Beautiful Jekyll