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: 
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: 
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: No such file or directory

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

 "$(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?

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.