小编Ste*_*hen的帖子

何时使用输出重定向创建文件?

我有一个在AIX ksh中运行的脚本,如下所示:

wc dir1/* dir2/* | {awk command to rearrange output} | {grep command to filter more} > dir2/output.txt
Run Code Online (Sandbox Code Playgroud)

这条线的前提条件是dir2/output.txt不存在.

问题是dir2/output.txt已经包含在输出中(它发生了数百次,没有问题).dir1和dir2是NFS安装的.

它与实现有关wc- 如果第一个参数需要很长时间怎么办?我想不是,因为我尝试了以下内容:

wc `sleep 5` *.txt > out.txt
Run Code Online (Sandbox Code Playgroud)

即使在这种情况下,out.txt也不会列出自己.

最后一点,在这个例子中使用了通配符,它​​们在实际脚本中使用.因此,如果首先发生扩展,为什么会出现这个问题呢?

dir2/output.txt实际创建的是什么时候?

filesystems aix ksh wc

2
推荐指数
1
解决办法
57
查看次数

标签 统计

aix ×1

filesystems ×1

ksh ×1

wc ×1