Is there a way in any Linux GUI file manager to create a custom shortcut to a bash file to be executed using the selected file(s)?

Example: Create hash sums of this file.

Bash script: makehashsums.bash

(md5sum $@
sha1sum $@
sha512sum $@
cksum $@
sum $@ ) >>$@.hashsums.txt

These are not all available hashsum algorithms, but the most common ones.

If possible, it would be great if it is supported for multiple files.

How can I add such a custom option to the context menu of a Linux file manager? (Is there one that supports this feature?)


Depending on your Desktop env it should be fairly simple to add your own scripts to the Open-with dialogue.

enter image description here

For the script itself, you just cycle through the command line arguments. ~/bin/hashies:


# Don't want to get upset by
# whitespace in filenames.

# Cycle through inputs
for file in $*
    # Get hashes for the files
    # Store per target file.
        md5sum $file
        sha1sum $file
        sha512sum $file
        cksum $file
        sum $file
    ) > ${file}.hashsums.txt

# Probably don't need to bother with
# restoring the input field separator
# as the sub-shell is about to die.

  • 1
    That should be for file to work with whitespace in file names (it's equivalent to for file in "$@", which is the correct way to loop over arguments). And you don't need to override IFS. – l0b0 Jul 1 at 8:35
  • Very useful answer, thanks. But can it also be added to the direct context menu that gets shown immediately after the right mouse click? – neverMind9 Jul 2 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.