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

Gnator
  • 11
  • 2
  • 1
    Filenames under *nix can't contain forward slashes. – Ignacio Vazquez-Abrams Jun 04 '13 at 22:32
  • Welcome to SO. what OS do you uses? (you tagged UNIX, but under UNIX the files doesn't contains f-slases, so probably it is the full path) in what language want open it? some details will speedup the answer, especially when you show what you already tried. and spend some time reading the http://stackoverflow.com/helpcenter – clt60 Jun 04 '13 at 22:35
  • 1
    I am using linux but the file I am downloading is from another OS thats why there are forward slashes. I am trying to unzip the file in terminal. I am completely sure the forward slashes are not due to directory / file system and it is the actual name of the file. – Gnator Jun 04 '13 at 22:46
  • 1
    @IgnacioVazquez-Abrams They can, because file names are just byte streams and not aware of the encoding. The restriction is imposed in the Unix kernel function `namei`. It treats a few values special, one of them is ASCII `0x2f` (`/`). One could use an encoding (encodings are only relevant for user level programs, not kernel functions) which translates `/` to another value than `0x2f`. – Marco Jun 04 '13 at 23:06
  • [How to remove a file with name starting with “-r” using cli](https://superuser.com/q/689825/241386), [Unix: Files starting with a dash, -](https://superuser.com/q/120078/241386), [Can't rename a file the name of which starts with a hyphen](https://superuser.com/q/510337/241386), [How do I delete a file whose name begins with “-” (hyphen a.k.a. dash or minus)?](https://unix.stackexchange.com/q/1519/44425) – phuclv Aug 20 '18 at 05:41

2 Answers2

1

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.

SBI
  • 769
  • 4
  • 9
-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).
fedorqui
  • 1,877
  • 1
  • 16
  • 36