Sed script within bash script produces unexpecte EOF error
Hi, I have a sed script which runs just fine at the command prompt, but when I include it in a bash script, it fails with: unexpected EOF while looking for matching `"' As always, any help or suggestions are greatly appreciated. It might take me an hour or two to reply to comments, thank you.
I'm working in Ubuntu 16.04 The script will eventually change two patterns within a log line (the combined sed command is commented out). The sed line is: Code:
sed -i -r "s#INIT\][0-9]{4}\s[A-Z][a-z]{2}\s[0-9]+#INIT]$ymdDate#g" $1 Code:
#!/bin/bash And last but not lease, here is the sample text: Code:
AV - Alert - "1557833239" --> RID: "110021"; RL: "2"; RG: "windows,applocker,"; RC: "Applocker audit mode program would have been blocked"; USER: "None"; SRCIP: "None"; HOSTNAME: "(DC1) 10.101.4.210->WinEvtLog"; LOCATION: "(DC1) 10.101.4.210->WinEvtLog"; EVENT: "[INIT]2019 May 14 07:53:51 WinEvtLog: Microsoft-Windows-AppLocker/EXE and DLL: Warning(8003): no source: KevinAdmin: TESTDOMAIN: 2012R2-DC1.testdomain.local: %SYSTEM32%\MMC.EXE was allowed to run but would have been prevented from running if the AppLocker policy were enforced.[END]"; Thanks again, Kevin |
Code:
ymdDate=$(date "%Y %b %d) |
Quote:
Thanks |
Quote:
After adding the missing second quote, your EOF error will turn in an error issued by the date command. What precise error will be issued probably depends on where you will put your second quote. You may want to re-read the manual page for date. |
I suggest you to use shellcheck.net to check your script. That will help you to solve your issues (except the date format - see man date).
|
Thanks for the great advice from both of you! shellcheck.net is totally awesome. Of course, my date formatting was an issue, but my biggest issue was not really thinking through what the EOF error was telling me. I was focused on the wrong line of code the whole time...
Thanks again, Kevin My new script is below. Advice is still appreciated, but it does work as intended. Code:
#!/bin/bash |
You can try adding the following as the second line of the script:
Code:
set -x |
Quote:
|
I usually use 'set -xv' ;) YMMV
|
All times are GMT -5. The time now is 12:48 PM. |