【问题标题】:Unix Program Using command line arguments check whether the given file exists in the given directory or not....?Unix程序使用命令行参数检查给定文件是否存在于给定目录中......?
【发布时间】:2014-06-21 09:10:09
【问题描述】:

我需要一个 unix 命令行参数程序,它将源文件名和目录名作为命令行参数并打印消息“是”,如果在给定目录中找到文件.....

【问题讨论】:

  • 欢迎来到 Stackoverflow。你试过什么?请在您的问题中提及。

标签: file unix directory command arguments


【解决方案1】:

这个怎么样?

#!/bin/sh
if [ -e $1 ]
then
   echo 'Yes'
fi

当然,您可以通过处理多个文件或在文件不存在时返回“否”来使其变得更好。

【讨论】:

    猜你喜欢
    • 2019-02-24
    • 2016-12-18
    • 2017-12-16
    • 2016-02-01
    • 2010-11-08
    • 2012-03-19
    • 2014-02-10
    • 2019-08-28
    • 1970-01-01
    相关资源
    最近更新 更多