【发布时间】:2018-05-17 19:39:26
【问题描述】:
我有一个在 linux 中运行良好的 bash 脚本,但是当我在我的 Mac 终端上运行它时它失败了,因为 splitcommand 的选项在 Mac 终端中略有不同。我的脚本是:
## Merge and half final two segments
last_file=`ls temp_filt.snplist_* | tail -n 1`
penultimate_file=`ls temp_filt.snplist_* | tail -n 2 | head -1`
cat $penultimate_file $last_file > temp && mv temp $penultimate_file
split -n l/2 $penultimate_file && mv xaa $penultimate_file; mv xab $last_file
脚本在最后一行失败,因为tcsh 中不存在-n l/2(Mac OS 10.x.x 中的默认 shell 环境)。我想知道 tcsh 中的等效脚本是什么。
有没有一种通用的方法可以在 Mac OS 终端中运行 linux 脚本,而无需更改脚本?
【问题讨论】:
-
tcsh十多年来一直没有成为 Mac OS 中的默认 shell(尽管它可能是您的默认 shell)。 -
@chepner:嗨,这里说的是什么? stackoverflow.com/a/8051196/5224239
-
正确;如果帐户在多个操作系统更新中持续存在,您可能仍将
tcsh作为您的登录 shell,但我建议切换到bash(或至少与 POSIX 兼容)。