mac unix脚本问题
我正在尝试编写一个脚本,将一个非常大的文件分解成较小的部分,然后将其发送到在后台运行的脚本。动机是如果脚本在后台运行,我可以并行运行。
这是我的代码, ./seq 的工作方式就像普通的 seq 命令(mac 没有)。 $1 是要分割的大文件。
echo "Splitting and Running Script"
for i in $(./seq 0 14000000 500000)
do
awk ' { if (NR>='$i' && NR<'$(($i+500000))') { print $0 > "xPart'$i'" } }' $1
python FastQ2Seq.py xPart$i &
done
wait
echo "Concatenating"
for k in *.out.seq
do
cat $k >> original.seq
done
for j in *.out.qul
do
cat $j >> original.qul
done
echo "Cleaning"
rm xPart*
我的问题是只创建了 xPart0,并且在程序挂起之前它只有 499995 行。我在脚本中添加了一些调试回显,并且我知道 awk 语句是停止脚本的原因。我就是不明白出了什么问题。
I'm trying to write a script that breaks up a VERY large file into smaller pieces that are then sent to a script that runs in the background. The motivation is that if the script is running in the background, I can run in parallel.
Here is my code, ./seq works just like the normal seq command (which mac doesn't have). and $1 is the huge file to be split.
echo "Splitting and Running Script"
for i in $(./seq 0 14000000 500000)
do
awk ' { if (NR>='$i' && NR<'$(($i+500000))') { print $0 > "xPart'$i'" } }' $1
python FastQ2Seq.py xPart$i &
done
wait
echo "Concatenating"
for k in *.out.seq
do
cat $k >> original.seq
done
for j in *.out.qul
do
cat $j >> original.qul
done
echo "Cleaning"
rm xPart*
My problem is that only xPart0 is made and it only has 499995 lines in it before the program hangs. I put some debugging echos in the script and I know the awk statement is what stops the script. I just can't figure out what's going wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
查看 split 命令 --
应该比循环运行 awk 更快、更可靠、更干净!
Check out the split command --
Should be much faster, reliable, and cleaner than running awk in a loop!
如果您的 seq 确实像标准 seq 一样工作,那么您就认为它是错误的。 seq 的正确命令行是:
因此您需要将 seq 命令行更改为:
If your seq truly works like the standard seq, you're calling it wrong. The proper command line for seq is:
So you would need to change your seq commandline to: