小编Hen*_*eld的帖子

从哪里运行 shell 脚本?

我在/usr/bin. 让我们称之为hello

它包含以下内容:

 echo "I am located in $PWD"
 echo "I am called from this directory: ???"
Run Code Online (Sandbox Code Playgroud)

hello/home/Documents我期望以下输出运行:

 echo "I am located in $PWD"
 echo "I am called from this directory: ???"
Run Code Online (Sandbox Code Playgroud)

如何获取运行脚本的目录路径?

linux shell bash directory

5
推荐指数
2
解决办法
3121
查看次数

tar 和 if 语句

我有一个脚本来检查一个文件是否存在于 tar 文件中,但出了点问题,因为它总是转到else脚本的一部分。我很确定它不应该是那样的。

日期采用“Mon dd”格式(1 月 11 日)。

echo "enter date: \c"
read date
tarfile=`tar -tvf tarfile.tar | grep some_file | grep "$date"`

if [ -f "$tarfile" ]; then
    echo "yes"
    else
    echo "no"
fi
Run Code Online (Sandbox Code Playgroud)

scripting tar ksh files

3
推荐指数
1
解决办法
3003
查看次数

标签 统计

bash ×1

directory ×1

files ×1

ksh ×1

linux ×1

scripting ×1

shell ×1

tar ×1