Pete B
Pete B

Reputation: 91

Bash statement meaning

I'm working on a project, and it's being run by an autoscript. The script has the following line:

./executable ./dev | grep -i "GET.*index.*200" > ./dev/logs/log1

I have my code writing to stdout, but it never gets written to log1. If I change it though and remove the grep command, it writes just fine. Any help would be appreciated, as I seemingly don't understand grep as well as I should.

Upvotes: 1

Views: 85

Answers (1)

fesia
fesia

Reputation: 25

You might try to redirect std output in your script "executable" using commands:

exec > ./dev/logs/log1
exec 2> ./dev/logs/errlog1

So, now not need to use ">" in the line

./executable ./dev | grep -i "GET.*index.*200"

Also I recommend you to use only absolute paths in scripts.

ps. [offtop] I can't write comments yet (not enough reputation).

Upvotes: 1

Related Questions