Base64 Decode

base64 -d file.b64 > file

Identify a File’s Type

less file           # display the contents of the file (as text)
file file           # identify the file type via magic bits
xxd file | less     # view the hex representation
strings file        # view string found in the file
ent file            # check the file entropy
                    # values 7.5+ are likely compressed or encrypted

Ol’ Switcheroo

If you need to perform an action on a file in a Linux box as soon as it’s created, use a bash script! An unthrottled while loop is fairly quick and good enough for many scenarios.

In this example, the goal is to move any file that matches /tmp/file-* to /tmp/moved. There’s nothing special about the file glob or the mv command, so replace them with whatever makes sense.

while true
do
    if compgen -G "/tmp/file-*" > /dev/null; then
        for f in /tmp/file-*; do
            mv $f /tmp/moved
            echo "Moved $f"
        done
    fi
done

compgen is pretty quick even in folders with a large number of files. There’s a good chance it’s not necessary for folders with only a few files, in which case you can remove the if statement and just use the for loop within the while loop.