Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to send each line of a file to another program's stdin, e.g.

input.txt

line1
line2
line3

I want to use the gnu parallel like this (i.e. pipe each line as stdin to the more command)

cat input.txt | parallel --pipe more

But it return

/bin/bash: -c: option requires an argument
/bin/bash: -c: option requires an argument
/bin/bash: -c: option requires an argument
/bin/bash: -c: option requires an argument
/bin/bash: -c: option requires an argument
/bin/bash: -c: option requires an argument
/bin/bash: -c: option requires an argument
/bin/bash: -c: option requires an argument

What I want is (maybe in different order due to the parallel)

line1
line2
line3

Anyone got the idea?

share|improve this question
    
Did you have a chance to go through the tutorial: gnu.org/software/parallel/parallel_tutorial.html –  Ole Tange Dec 27 '13 at 2:43
add comment

2 Answers

Try:

cat input.txt | parallel -N1 --pipe wc
share|improve this answer
    
Both not work. (No such file or directory). more is just an example for me to test the command which read from stdin instead of argument. What I want is to parallel every line of input.txt and feed them into a customized program that read from stdin and print the processed output. Is it clear now? –  Howard Dec 25 '13 at 4:23
    
What does 'parallel --version' give? Are you sure it is GNU Parallel? –  Ole Tange Dec 26 '13 at 19:00
    
WARNING: YOU ARE USING --tollef. IF THINGS ARE ACTING WEIRD USE --gnu. GNU parallel 20121122 –  Howard Dec 27 '13 at 16:05
    
Disable --tollef (often it is in /etc/parallel/config) then walk through the tutorial gnu.org/software/parallel/parallel_tutorial.html –  Ole Tange Dec 27 '13 at 20:25
1  
It is not clear whether your program only only reads a single line or more lines. If we assume your program is 'wc', then this works: 'cat input.txt | parallel --pipe wc' or if you want a single line: 'cat input.txt | parallel -N1 --pipe wc' –  Ole Tange Dec 27 '13 at 20:28
show 1 more comment

Try with ....

cat input.txt | xargs -I {} more {}

or ... cat input.txt | parallel more

share|improve this answer
    
I want to pass as stdin to more rather than argument. –  Howard Dec 25 '13 at 4:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.