1

I need to open a file with filename that contains forward slashes. I am wondering how I can do that. I have been searching through Google and I can't seem to find a way.

Thanks

migrated from stackoverflow.com Jun 4 '13 at 22:41

This question came from our site for professional and enthusiast programmers.

2

Turning my comment into a bit of a possibly useful answer. Try renaming the file.

ls -i

Will give you the inode number of the file. You can then use a combination of find and mv to rename the file as follows:

find . -inum "inode-number-from-ls -i" -exec mv {} "newfilename" \;

Give the file a "normal" new file name and you're good to go.

  • Good one! Should work. – fedorqui Jun 5 '13 at 8:03
  • Why on Earth is this going to work? If find can pass a valid name to mv, then it's not a problem for a user to do the same. – firegurafiku Apr 18 '17 at 22:55
  • Because the name that find passes will be correctly encoded, unlike what the user would type on the terminal. – SBI Apr 19 '17 at 8:24
-1

It must be a Windows file. You have several ways to solve this:

  • Wrap the name with quotes: vi "file/name".
  • Use tab to complete the name. It will give you the proper way to write it.
  • Find a pattern and use *. If the name of the file is file/name, you can do vi fil* and this will be opened (together with others that can have same pattern).
  • The filesystem calls will interpret / as the directory separator regardless of how it's specified on the command line. – Ignacio Vazquez-Abrams Jun 4 '13 at 22:35
  • 1
    Yes, I see. Nevertheless, the fabulous tab can provide a way to escape it, doesn't it? – fedorqui Jun 4 '13 at 22:37
  • 1
    I tried all three methods unfortunately none worked. I am wondering if I can somehow rename the entire file on a program using java or something that isn't as aware of the encoding. – Gnator Jun 4 '13 at 23:11
  • What about mv file* newname? – fedorqui Jun 4 '13 at 23:15
  • Unfortunately it didn't work also. I suspect moving the file around corrupts the file because it is a zip file originally. – Gnator Jun 4 '13 at 23:34

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.