我有一个在Linux上运行良好的Bash脚本,但当我在Mac终端上运行它时,由于Mac终端中split
命令的选项略有不同,因此它会失败。我的脚本如下:
## 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
脚本在最后一行失败,因为在Mac OS 10.x.x中的默认shell环境tcsh中不存在“-n l/2”选项。我想知道在tcsh中等效的脚本是什么。
是否有通用的方法可以在Mac OS终端中运行Linux脚本,而无需更改脚本?
tcsh
作为登录shell,但我建议切换到bash
(或至少是符合POSIX标准的其他shell)。 - chepner