Home > Net >  Escaping characters in bash
Escaping characters in bash

Time:03-30

  • 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

CodePudding user response:

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

CodePudding user response:

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
  • Related