通过提供命令molcas -f file.input
来运行量子化学计算。我现在需要将molcas -f
放入一个脚本中,该脚本也是tail
是生成的file.log的最后100行,以便我快速确认所有事情都按其应有的方式完成。所以,我要运行脚本run.sh
:制作从命令行读取参数的脚本
#!/bin/bash
molcas -f [here read the file.input from command line]
tail -100 [here read the file.log]
问题是我怎样才能使脚本阅读我给的参数,然后在自己的输出文件中找到(具有相同的文件名,但有不同的延伸)。
后续
说我有一堆编号文件file-1, file-2, ..., file-n
。我会节省时间,如果我,而不是运行
./run.sh file-1.input file-1.log
我跑
./run.sh n n
或
./run.sh n.input n.log
假设数n
的实际文件名和位置在给定脚本。可以这样做吗?
请参阅http://stackoverflow.com/documentation/bash/4797/internal-variables/16884/1-2-3-etc#t=201703091327041201335和http://stackoverflow.com/documentation/bash/502/ shell-parameter-expansion/7580/replace-pattern-in-string#t = 201703091327440062742 – Sundeep