Equal sign in filename

Some data files that I process have equal signs in the filename and I haven’t found a way to quote these filenames so that GMT will read the file. If it matters, I’m running GMT 6.2 (installed via conda) on macOS 11.6. This is the error message:

$ gmt info file_150=E_name.gmt
gmtinfo [ERROR]: Cannot find file file_150

I’ve tried double quotes, single quotes, various numbers of back slashes, and always end up piping the file contents into GMT with awk or cat. I suspect “=” is reserved by GMT to identify the file grid type and automatically splits the string on the first “=”.

Can someone A) figure out how to quote filenames containing equals signs or B) confirm that this isn’t going to work? I think either will help me build my case for changing the file naming convention [ours, not GMT’s].

Thank you

Hm, same problem. You can always use substitution to rename everything containing the equal sign and replacing it with an underscore ?

I think either will help me build my case for changing the file naming convention.

Well, there’s already many ressources on the web to build your case !

for nn in $(ls *=*)
do 
    cp $nn $(echo $nn | awk -F[=] '{printf "copy_%s%s",$1,$2}')
done

gmt [...]

rm -f copy_*

That’s a good idea, and probably easy enough to work into scripts to do this if the dirty filenames are detected (my filenames already use underscores or dashes instead). I should figure out how to use the GMT helper functions for temporary directories. I’m still hoping I can get the naming convention changed…
Thanks!

If you mean accepting = in file names I would say No way. A lot of things depend on that =

1 Like

No, I meant convincing my colleagues to stop putting the = in the filenames in the first place :slight_smile:

1 Like