1

ファイルと 1 行のコードをプログラムに渡そうとしています。

私の行:

i := 1;

私のファイル(ファイル):

blah1
blah2
blah3

プログラムへの入力:

i := 1;
blah1
blah2
blah3

次のような1行になると思います。

example < `echo "i := 1;\n" cat file`

またはそのようなもの

4

3 に答える 3

2
{ echo 'i := 1;' ; cat myfile.txt ; } | example
于 2011-08-25T08:39:01.043 に答える
1
(
echo "i := 1"
cat file
) | program
于 2011-08-25T08:39:38.860 に答える
1

必要なのは、ここに文字列です:

example <<< `echo "i:=1" && cat file`

bash マニュアルから:

3.6.7 Here Strings

A variant of here documents, the format is:

     <<< word

The word is expanded and supplied to the command on its standard input. 
于 2011-08-25T08:39:29.300 に答える