I would like to improve a simple script i made.
While it works fine for a single argument and does what i want i have issues making it to run in parallel or at the same time for all my argument values. I would like to improve it to run on multiple arguments and output my grep findings at the same time and not in sequence, while is not the good choice ? Any help to make this output work would be really appreciated. Thank you very much.
- i have multiple files file1.log file1.txt file2.log file2.txt
- need to grep something from *.log and something from *.txt
- output the grep lines for all arguments into the same echo.
my script so far looks like this :
#!/bin/bash
filename=$@
error=$(grep 'ERROR' ${filename}.l)
phone=$(grep 'phone' ${filename}.e)
invalid=$(grep 'invalid' ${filename}.l)
while true ; do
echo -e " Start of message \n :
$error \n
$invalid \n
$phone \n
End of message \n "
break
done
exit
This is how i would like the output to look
Start of message
error form file1
Phone number from file1
Invalid from file1
error form file2
Phone number from file2
Invalid from file2
error form file3
Phone number from file3
Invalid from file3
etc
End of message