简体   繁体   中英

Piping in c w/h terminal command: ./process arg | ./process arg

I have 2 files, one that generates random integers with two arguments, number of integers and the seed. The other file searches for a value in an array.

What I want to do is for the first file to give its randomly generated numbers as an array input for the second file.

like so in terminal.

./random_no 100 50 | ./find 42 -

I know this is meant to pipe the input from random_no into find.

the problem is I don't know how to receive or manipulate that input from the find file.

if it doesn't make sense or you want to see code as an example please tell me. Thanks :)

You should clarify you question. Which operating system are we dealing with? AIX, Linux? Also it helps if you clarified what is it that you are trying to achieve as there may be better ways than what you are trying to do.

Pipe uses plain text via the stdout and stdin .... you are not working with objects, like an array.

random_no need to write to stdout and find would need to read from stdin.

but really you could use many standard command line utilities to achieve different tasks and should not need to write a C application.

for example to "find" 42 from the output of random_no

./random_no 100 50 | grep 42

But what does that achieve exactly?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM