linux - 将键盘命令编码到 Bash 脚本中

标签 linux bash unix keyboard qsub

我有以下方法使用 qsub 提交集群作业:

 Submitting jobs from standard input
       To submit a PBS job by typing job specifications at the command line, the user types

              qsub [options] <return>

       then types any directives, then any tasks, followed by

              (in UNIX)     CTRL-D on a line by itself
              (in Windows)  CTRL-Z <return>

       to terminate the input.

有没有一种方法可以在 bash 脚本中对 RETURN 和 CTRL-D 进行编码,以便我们可以执行以下操作:

for i in path/*.txt; do echo "$i";  qsub [RETURN] /path2/mycode $i; [CTRL-D]; done

最佳答案

你应该通过管道使用重定向:

for i in path/*.txt; do
  echo "$i";
  echo "/path2/mycode $i" | qsub;
done

关于linux - 将键盘命令编码到 Bash 脚本中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/638202/

相关文章:

c++ - 如何读取 C++ 中 system() 调用的结果?

linux - 使用nohup启动java程序进入循环

string - 如何使用 sed 在 bash 脚本中追加字符串?

bash - 使用bash从文件中提取文本

c++ - 使用unix下载html文件

linux - 在linux中执行一个目录

bash - 我需要 cat 将 heredoc 写入文件吗?

unix - 在 SAP ABAP 中创建文件时如何设置(unix)权限?

c - 如何在 CTRL-C 之前保持输入

c++ - 如何在 GDB 中漂亮地打印 STL 容器?