1

good day all

this is part of a larger function, but I get this error and can't figure out what is the problem:

script name "connected.sh"

running this

 cat "$logfile" | grep "$searchstring" 

returns results perfectly, however when I insert this into the bash function, with the following code: (this is line 41, line 40 I create the tempout file & 41 is a simple echo)

 "$(cat "$logfile" | grep "$searchstring")" >> "$tempout" 

this is printed in the terminal:

./connected.sh: line 41: Fri Nov 6 14:29:14 2015 us=68416 xyz/x.x.x.x.184:44595 MULTI: primary virtual IP for xyz/x.x.x.x:44595: 10.0.0.12 Fri Nov 6 14:29:27 2015 us=606987 xyz/x.x.x.x:40223 MULTI: primary virtual IP for xyz/1x.x.x.x:40223: 10.0.0.10 Fri Nov 6 15:46:58 2015 us=712031 xyz/x.x.x.x4:54911 MULTI: primary virtual IP for xyz/x.x.x.x:54911: 10.0.0.12: No such file or directory 

what is causing this "./connected.sh: line 41: ... No such file or directory"

1 Answer 1

4
 "$(cat "$logfile" | grep "$searchstring")" >> "$tempout 

Is executing the line found by grep in your $logfile (that is what the "$" at the beginning of your outer parenthesis does) and then storing the output in $tempout. From your explanation it appears you are trying to redirect the line found by grep into $tempout. which would just be:

cat "$logfile" | grep "$searchstring" >> "$tempout" 

Is that what you're trying to do?

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.