Other articles

  1. grep tip: Only print matches

    Problem: You want grep to print only the match, not the entire line that contains the match

    Solution: Use the -o command line option

    If you use grep on a file list instead of stdin, you might want to add the command line option -h to suppress the filename the ...

    read more
  2. How to solve LT_INIT command not found on Linux

    Problem: You are running a configure script on Linux. It exits with a message like this:

    ./configure: line 3638: LT_INIT: command not found


    You’re missing GNU libtool. Install it using your distribution’s package manager, for example on Ubuntu use

    sudo apt-get install libtool

    LT_INIT in the error ...

    read more
  3. Shell: Strip extension and directory from path

    Problem: In the Linux shell, you have a path, e.g. ../images/photo.jpg and you want to strip the extension and the directory from it to get only photo.jpg

    Essentially this is a combination of two problems I featured before. To find out how to strip the directory ...

    read more
  4. Shell: Strip directory from path

    Problem: In the Linux shell, you have  a file path and you want to strip everything but the filename, for example  you have the path ../images/photo.jpg  and want only photo.jpg

    Solution: Assuming the filename is stored in the shell variable $filename, use this snippet:

    echo $filename | rev ...
    read more
  5. Shell: Strip extension from filename

    Problem: You have a filename in the Linux shell and want to strip/remove the filename extension from it - e.g. if you have myarchive.zip, you want to get only myarchive as output.

    Solution: Let’s assume your original filename is saved in the bash variable $filename. Then you ...

    read more