Extract specific line of code using awk (or non-awk) from a log file
<p>I am trying to find a way to extract scripts from the log file generated.</p>

<p>I am stuck at a place where a command calls for multiple files and the script separates them with a trailing "\" for line continuity. For example, a sample script is:</p>

<pre><code>my_command -option \
file1 \
file2 \
file3
my_command2 .. ..
</code></pre>

<p>It looked easy but somehow the trick is not hitting me at this point.
Please help.
Every line in the log starts with a specific identifier for command, like:</p>

<pre><code>:: Script_Command:: my_command -option \
:: file1 \
:: file2 \
:: file3 
:: Info lines....
:: More info lines ...
:: Script_Command:: my_command2 ... ..
:: Info lines ...
</code></pre>

<p>So I used:</p>

<pre><code>awk '/Script_Command/ {print }'
</code></pre>

<p>And then I tried to combine it with a if condition with:</p>

<pre><code>awk '/Script_Command/ {print substr(length(),1)}'
</code></pre>

<p>But the entire thing is not falling in place.
Please help.</p>

<p>Edit:
The closest I got is here:</p>

<pre><code>awk '{if ($NF=="\\" ||  == "Script_Command::") print ;}' file
</code></pre>

<p>It still leaves the file3 line as it does not match anything.</p>

<p>Pure intention is:
1. When Script_Command is matched, print line.
2. When "\" is matched, print the next line.
3. When both are matched, print line and next line.</p>