Want to Gzip my all the .csv files into a gzip file.

I am using this command.

gzip *.csv;

Problem File contains '//' in its name that's why command is giving error.

Error : - '//File.csv' is not a directory or file.

So please suggest me what ways i can do this successfully.

one solution i thought.

gzip '//File1.csv' '//File2.csv' '//File3.csv'

Please suggest me if this is the right way to perform the same.

  • 2
    / is not a valid character in a filename in any *nix filesystem I have used. In fact, it's not even valid in Windows filesystems such as NTFS.
    – jordanm
    Dec 17 '14 at 5:48
  • Its coming because we have some old legacy code. Best solution is change that but it can create a mess for us.
    – Java_Alert
    Dec 17 '14 at 6:19
  • Agree with @jordanm - it's not possible to create a file with a '/' (or \0) in the name, with any standard, user-level programs. It doesn't matter how legacy your code is. Can you post a screen shot, or more details about where the files are coming from? Is it a samba mount for example? stackoverflow.com/questions/1976007/… Dec 17 '14 at 7:27
  • Next time, please do not cross post your question to multiple sites.
    – slhck
    Dec 17 '14 at 8:13
  • It's impossible to have the character / in a file name. What is the actual file name? What is the exact error message? Always copy-paste error messages. Dec 17 '14 at 22:10

There are only two characters that are really not allowed in a filename in unix, and you've got one of them.


Are the files on a usb stick formatted as some exotic file system? You really have to try hard to get a "/" into a filename in unix.

http://www.unix.com/tips-and-tutorials/198879-how-manage-file-names-special-characters.html has some suggestions, the easiest of which is to go back to what ever system produced the files in the first place.


Use a loop! for F in *.csv; do gzip "$F"; done will work because of the quotes around $F

Not the answer you're looking for? Browse other questions tagged or ask your own question.