I am trying to stdin only lines from 1 to 1000 from a file (output.txt) to a while loop.
I have tried something like this:
#!/bin/bash while read -r line; do echo "$line" done < (sed -n 1,1000p data/output.txt) Just tried:
#!/bin/bash while read -r line; do echo "$line" done < <(sed -n 1,1000p data/output.txt) adding another angular bracket "<" did the trick... If someone can explain that could be interesting.
Thanks
You seem to want to pipe the output from one command to another. If so, use a pipe:
sed -n 1,1000p data/output.txt | while read -r line; do echo "$line"; done Or, using the right tool for the right job:
head -1000 data/output.txt | while read -r ; do something; done
bashas#!/bin/bashor wherever it is installed in your machine