Skip to content

Shell

Check for all shell scripts executable from a folder which might not have .sh file extension, then copy to another folder

find dcm4che-5.31.0/bin -type f -exec sh -c 'file "$1" | grep -q "shell script"' _ {} \; -exec cp {} tmp \;

Oneliner

check if root

[ "$EUID" -ne 0 ] && { echo "Please run as root!"; exit; }

echo OK if command exist

[[ $(command -v j2) ]] && echo "OK" || echo "KO"

tput

Manipulate terminal, e.g. set colors, etc. https://linuxcommand.org/lc3_adv_tput.php

Resets all currently set colors, text properties, and so on, then resets them

tput sgr0

Complete Character Test

    #!/bin/bash

    # tput_characters - Test various character attributes

    clear

    echo "tput character test"
    echo "==================="
    echo

    tput bold;  echo "This text has the bold attribute.";     tput sgr0

    tput smul;  echo "This text is underlined (smul).";       tput rmul

    # Most terminal emulators do not support blinking text (though xterm
    # does) because blinking text is considered to be in bad taste ;-)
    tput blink; echo "This text is blinking (blink).";        tput sgr0

    tput rev;   echo "This text has the reverse attribute";   tput sgr0

    # Standout mode is reverse on many terminals, bold on others. 
    tput smso;  echo "This text is in standout mode (smso)."; tput rmso

    tput sgr0
    echo