问题:
I am writing a shell script to run under the KornShell (ksh) on AIX. 我正在编写一个shell脚本,在AIX上的KornShell(ksh)下运行。 I would like to use the mkdir
command to create a directory. 我想使用mkdir
命令创建一个目录。 But the directory may already exist, in which case I do not want to do anything. 但目录可能已经存在,在这种情况下我不想做任何事情。 So I want to either test to see that the directory does not exist, or suppress the "File exists" error that mkdir
throws when it tries to create an existing directory. 因此,我想测试以查看目录不存在,或者抑制mkdir
在尝试创建现有目录时抛出的“文件存在”错误。
Any thoughts on how best to do this? 有关如何最好地做到这一点的任何想法?
解决方案:
参考一: https://stackoom.com/question/3KWA/如果目录尚不存在-如何mkdir参考二: https://oldbug.net/q/3KWA/How-to-mkdir-only-if-a-dir-does-not-already-exist
来源:oschina
链接:https://my.oschina.net/u/4438370/blog/4300928