Edit --> Configure Custom Actions...) the command I use is:" /> Edit --> Configure Custom Actions...) the command I use is:" /> Edit --> Configure Custom Actions...) the command I use is:"/>

Escaping characters in bash

405 Views Asked by At
  • I use thunar as a file manager
  • I want to use "custom actions" on certain files (Thunar --> Edit --> Configure Custom Actions...)
  • the command I use is: xfce4-terminal -e "md5sum '%F'" --hold

This works fine, except when the file path or file name contains a space. It just won't work as intended because the file can then not be found.

I think this is because the spaces in the file path are not automatically escaped

How do I solve this problem? Thank you in advance

2

There are 2 best solutions below

0
Socowi On BEST ANSWER

Seems like Thunar replaces %F with (potentially multiple) correctly quoted paths. Putting this inside quotes will ruin the already perfect quoting. From https://docs.xfce.org/xfce/thunar/custom-actions

Never quote field codes

You need a way to pass an argument list to a command running inside xfce4-terminal. Luckily man xfce4-terminal lists:

-x, --execute Execute the remainder of the command line inside the terminal

Therefore, try

xfce4-terminal --hold -x md5sum %F
1
Lou On

You can easily escape a character with by placing a \ in front of it.