質問

We are using crontab to schedule jobs and it was not picking the files for processing that have [ or ] or ¿ . Is there any limitation in giving file name or these characters means something in UNIX? Is there any other variables like these we shouldnt use in file name?? Thanks in advance.

役に立ちましたか?

解決

Following are general rules for both Linux, and Unix (including *BSD) like systems:

  1. All file names are case sensitive. So filename vivek.txt Vivek.txt VIVEK.txt all are three different files.
  2. You can use upper and lowercase letters, numbers, "." (dot), and "_" (underscore) symbols.
  3. You can use other special characters such as blank space, but they are hard to use and it is better to avoid them.
  4. In short, filenames may contain any character except / (root directory), which is reserved as the separator between files and directories in a pathname. You cannot use the null character.
  5. No need to use . (dot) in a filename. Some time dot improves readability of filenames.
  6. And you can use dot based filename extension to identify file. For example:

    .sh = Shell file
    .tar.gz = Compressed archive
    
  7. Most modern Linux and UNIX limit filename to 255 characters (255 bytes). However, some older version of UNIX system limits filenames to 14 characters only.
  8. A filename must be unique inside its directory. For example, inside /home/vivek directory you cannot create a demo.txt file and demo.txt directory name. However, other directory may have files with the same names. For example, you can create demo.txt directory in /tmp.

Linux / UNIX: Reserved Characters And Words

Avoid using the following characters from appearing in file names:

/
>
<
|
:
&

Please note that Linux and UNIX allows white spaces, <, >, |, \, :, (, ), &, ;, as well as wildcards such as ? and *, to be quoted or escaped using \ symbol.

It will be good if you can avoid white spaces in your filename. It will make your scripting a lot more easier.

I got the answer from this link. I am just pasting it here so that this info will be available even if that website goes down.

他のヒント

The only characters that are actually illegal in *nix filenames are / (reserved as the directory separator) and NUL (because it's the C string terminator). Everything else is fair game, although various utilities may fail on certain characters - typically characters that have special meaning to the shell. These will need quoting or escaping to be handled correctly.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top