내가 대충 이런식으로 c 코드를 썼다고 치자
#include <stdio.h>
int main()
{
int a;
scanf('a',%d);
printf('input is %d',a);
}
이런 코드임 근데 이걸 sh로 실행하고 싶음 그러니까 gcc로 컴파일 한 결과를 a.out이라 치고
나는 그러니까 a에다가 자동으로 1부터 10까지 넣고 싶음 그래서 sh코드를 이런식으로 짰음
파일 이름 : sex.run
./a.out 1
./a.out 2
..
.
.
.
.
./a.out 10
이런식으로 해서 a.out을 실행시킨 다음 1부터 10까지 넣고 싶었음
근데 당연히 저 코드로는 안됨... 그래서 그런데 너 sex.run을 어떤식으로 작성해야 내가 원하는대로 a.out을 실행한 다음에 1넣고 a.out 실행하고 2 넣고..... 이걸 반복할수 있음??
&a
https://stackoverflow.com/questions/26697627/how-to-pipe-data-to-a-program-which-calls-scanf-and-read-in-linux
#include int main (int argc, char **argv) { int a; scanf("%d", &a); printf("input is %d\n",a); }
echo 111 | ./sample
input is 111