To give STDIN for Sed? Pseudocommand 

echo '1,2,3,5' | sed -n data.txt


which gives

sed: 1: "data.txt": extra characters at the end of d command


I want to give linenumbers for search from other command. 
Actually awk is giving those numbers from this thread. 

data.txt:

hello 
amigo
this line 3
and here we go 4
and 5 is here


where output should be 

hello 
amigo
this line 3
and 5 is here


How can you give sed those linenumbers?
Basically you can do something like

eval $(echo sed $(for i in 1 2 3 5; do echo "-e ${i}p"; done) -n data.txt )




To read the line numbers from a file containing the numbers, separated by space, use

eval $(echo sed $(for i in $(&lt; line-numbers.txt); do echo "-e ${i}p"; done) -n data.txt )


In this case, you can use any command which produces a list of line number instead of the &lt; line-numbers.txt part.



Or, if the numbers in the file are separated by ,

eval $(echo sed $(for i in $(tr \, ' ' &lt; line-numbers.txt); do echo "-e ${i}p"; done) -n data.txt )


(and again, the command can be anything producing line numbers separated by ,)