I am trying to remove and replace quotation marks that are present in a file name. For example, I would like to change:
$ ls abc"def"ghi"jkl"mno to this
$ ls abc:def:ghi:jkl:mno In trying to solve this, I came across How to rename a bunch of files to eliminate quote marks, which is exactly what I want to do. However, it didn't work for my case. To figure out why, I tried creating a test file like this:
$ touch abba\"abba\"cde\"cde\"efef With this file, the solutions I came across (such as mentioned above) worked. But why didn't it work for the first file?
One thing I discovered was that bash command completion sees them differently. If I type in
$ ls abb<tab> bash will complete the filename like so:
$ abba\"abba\"cde\"cde\"efef just as I created it. But for the original file, bash completion went like this:
$ ls abc<tab> results in
$ abc"def"ghi"jkl"mno So in the test case file, there is an escape of the quotation marks, and in the other case (the file I really want to rename), there is no escaping of the the quotation marks. I don't know how the original files were named.
Can anyone explain why bash sees these names differently, and how I would go about renaming my file?
mv 'abc"def"ghi"jkl"mno' 'abc:def:ghi:jkl:mno'?ls abb<tab>is completing an argument for thelscommand, whileabc<tab>is completing a command using the default completion (not associated with any specific command).printf '%q\n' *in the directory where the file lives will show each file name in an unambiguous form.