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
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
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.
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 – 2017-04-18T22:55:27.160
Because the name that find passes will be correctly encoded, unlike what the user would type on the terminal. – SBI – 2017-04-19T08:24:49.380
Good one! Should work. – fedorqui – 2013-06-05T08:03:45.123
-1
It must be a Windows file. You have several ways to solve this:
vi "file/name"
. *
. 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 – 2013-06-04T22:35:43.947
1Yes, I see. Nevertheless, the fabulous tab can provide a way to escape it, doesn't it? – fedorqui – 2013-06-04T22:37:56.743
1I 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 – 2013-06-04T23:11:14.703
What about mv file* newname
? – fedorqui – 2013-06-04T23:15:04.413
Unfortunately it didn't work also. I suspect moving the file around corrupts the file because it is a zip file originally. – Gnator – 2013-06-04T23:34:33.527
You have to rename the file using the inode value. – SBI – 2013-06-05T07:03:36.030
How to remove a file with name starting with “-r” using cli, Unix: Files starting with a dash, -, Can't rename a file the name of which starts with a hyphen, How do I delete a file whose name begins with “-” (hyphen a.k.a. dash or minus)? – phuclv – 2018-08-20T05:41:19.783
1Filenames under *nix can't contain forward slashes. – Ignacio Vazquez-Abrams – 2013-06-04T22:32:18.070
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
– jm666 – 2013-06-04T22:35:32.8731I 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 – 2013-06-04T22:46:57.653
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 ASCII0x2f
(/
). One could use an encoding (encodings are only relevant for user level programs, not kernel functions) which translates/
to another value than0x2f
. – Marco – 2013-06-04T23:06:56.147