0

I can do the following:

sort -nbms file1.txt file2.txt

and it will merge the two already sorted files.

What I wish to do is take the output from two commands (its sorted) and pipe it in as input instead of file1.txt and file2.txt.

Is that possible?

1
0

Looks like a job for compound statements in shell. Like this:

{ command1; command2; } | command3

In bash you might also use the command redirection syntax:

command3 < <(command1; command2)

The above are a general examples which work for any command accepting input from stdin. In your case of course you want to place sort -nbms as "command3", and you might also use the process substitution syntax in place of each input file:

sort -nbms <(command1) <(command2)

This latter can be used with commands that, like sort, accept more than one input file or that don’t accept stdin at all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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