auditory
auditory

Reputation: 177

bash process substitution hangs for script output

this works:

sort <(seq 10)

but this does not work

sort <(seq.sh 10)

where seq.sh looks like

#/bin/bash
seq $1

How I can make seq.sh work for this?

-- edit -- sorry for typo. seq.sh is excutable and has correct shabang line.

I guess it is related with EOF something. This works as well with trailing &

sort <(./seq.sh 10 &)

Upvotes: 0

Views: 160

Answers (2)

9Breaker
9Breaker

Reputation: 724

You may need to add the ! to the shebang.

#!/bin/bash

Also I would make sure that the shell script is executable.

chmod +x seq.sh

lastly, pipe into sort: (the example has an input of 10)

./seq.sh 10 | sort

This was my output:

user@MBP:~/Desktop$ ./seq.sh 10 | sort
1
10
2
3
4
5
6
7
8
9

Upvotes: 1

jgmh
jgmh

Reputation: 689

It works if you use seq.sh as a path, for example ./seq.sh or its absolute path. Remember to make it executable.

Upvotes: 1

Related Questions