Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 重定向用空格分隔的输入_Bash_Shell - Fatal编程技术网

Bash 重定向用空格分隔的输入

Bash 重定向用空格分隔的输入,bash,shell,Bash,Shell,大家好,我有一个问题,关于将输入输入到我编写的这个简单bash脚本。它所做的只是在编译操作中添加一组标志,这样我就不用每次都在自己身上写它们了。我可以使用echo myprogram.c-o myprogram-llibrary./Compile来运行它。 但是我找不到一种方法来以我期望的方式运行它,/Compile

大家好,我有一个问题,关于将输入输入到我编写的这个简单bash脚本。它所做的只是在编译操作中添加一组标志,这样我就不用每次都在自己身上写它们了。我可以使用echo myprogram.c-o myprogram-llibrary./Compile来运行它。 但是我找不到一种方法来以我期望的方式运行它,
/Compile
我尝试了一些引号和括号的组合,但都没有效果,有人能告诉我如何使用redirect-input命令提供与echo相同的输入吗

#!/bin/bash
# File name Compile
#Shortcut to compile with all the required flags, name defaulting to
#first input ending in .c
echo "Enter inputs: "
read inputs
gcc -Wall -W -pedantic -std=c89 -g -O $inputs
exit 0
您可以使用:

您可以使用:


只需将shell更改为:

#!/bin/bash
gcc -Wall -W -pedantic -std=c89 -g -O "$@"
然后您只能写入(无需重定向):


顺便说一句,不要在这个shell的末尾显式地写入
退出0
。当gcc成功时它是多余的,当gcc失败时它是错误的(退出代码1将被覆盖)。

只需将shell更改为:

#!/bin/bash
gcc -Wall -W -pedantic -std=c89 -g -O "$@"
然后您只能写入(无需重定向):

顺便说一句,不要在这个shell的末尾显式地写入
退出0
。当gcc成功时,它是冗余的,当gcc失败时,它是错误的(退出代码1将被覆盖)

#!/bin/bash
gcc -Wall -W -pedantic -std=c89 -g -O "$@"
./Compile myprogram.c -o myprogram -llibrary