【问题标题】:Why is tail not working here?为什么尾巴在这里不起作用?
【发布时间】:2016-01-21 17:33:16
【问题描述】:

我的 csh 脚本

#!/bin/csh
# C-schell script to increase the boundingbox....

echo '%\!PS-Adobe-3.0 EPSF-3.0'
echo '%%BoundingBox: 0 0 1100 1100'
tail +3 $argv[1]

在这里调用

csh bbox.csh plt >! plt_P1.ps

但我有

csh -f bbox.csh plt
tail: cannot open ‘+3’ for reading: No such file or directory

tail 应该做什么?写代码的人用的是 Darwin,我在 Ubuntu 14.04 上。

【问题讨论】:

  • 使用 tail -n+3 ... 。没有-n 的表单已经被弃用了几十年,并不是所有的tail 实现仍然允许它。

标签: linux bash csh


【解决方案1】:

GNU tail 不支持这种语法。请改用tail -n +3 "$argv[1]"

如果您正在使用例如bash、dash 或 zsh 作为 shell: 您还需要在命令行中将>! 修改为>

csh bbox.csh plt > plt_P1.ps

【讨论】:

  • @jofel 工作正常!但是 csh bbox.csh plt >! plt_P1.ps,我应该如何改变>!对于 ubuntu?Bash 脚本在 Darwin 中是不同的。
  • 只需使用> 而不是>!
【解决方案2】:

Tail 打印文件的最后 10 行(默认)。使用 -n 选项来获得更多行。

【讨论】:

    猜你喜欢
    • 2013-05-16
    • 2019-02-10
    • 2017-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多