How to run commands with pipe from text file?

Hello,

I have standard loop

while read -r info; do
command $info
done < info

in info text file I have multiple commands each on line that I want to execute. When I used them in console they worked, but not with this loop.

This is one of the commands in info file:

grep --line-buffered "title" dir/file.html | grep -Po '(?<=>)(.*)(?=<)'

It works with first grep , but not with second one. I found --line-buffered parameter, but didn't helped. Can somebody help me?

Please always include the operating system and shell you're using whenever you start a thread in this forum. Some utilities are not available on all operating systems. Some options on common utilities vary from operating system to operating system. Some shell options (such as arrays) vary from shell to shell. If we don't know what operating system and shell you're using, it is sometimes hard to guess at what the real problem is that you're describing, and hard to create suggestions that will work in your environment.

The command utility takes a "simple" command (a utility and its arguments) as parameters. If does not take a "pipeline", a "compound" command, a "list", an if , a for , or an until loop, or a case statement.

If you want your shell to execute a pipeline (or one of the other non-simple commands listed above) and return the exit status of that pipeline, you need something more like:

shell -c "pipeline"

where shell is the name of the shell you're using and pipeline is the pipeline you want your shell to run.

Your snippet seems to want to execute every single line in the info file - why not source your file immediately, or just run it (after having chmod ed it executable)?

oh....

Thanks