Note that there are some explanatory texts on larger screens.

plurals
  1. POfind grep works in commandline but fails in script; autoescaping by shell?
    primarykey
    data
    text
    <p><b>UPDATE</b>:<br> After having tried it again, it turns out that the script works exactly as it should. I must have been too tired and doing something stupid that lead me to think the script was wrong when it was in fact me myself. :-(<br> Many thx for your help chepner, shellter, William, glenn and Jonathan, I guess my confusion was in fact triggered somehow by me executing the find on the current directory "."<br> Thx for for hints!</p> <p>This thread is ready to be closed.</p> <blockquote> <p>Consider the following:</p> <pre><code>find . | grep -E ".*\.log$" </code></pre> <p>If this is run at the command line, it works as expected, namely printing out all directories and files that end in <code>.log</code></p> <p>However when in a script, for example:</p> <pre><code>#!/bin/sh find . | grep -E ".*\.log$" </code></pre> <p>it fails. When turning on <code>set -x</code> to inspect, I noticed that during the script execution the regular expression <b>.*.log$</b> is (auto-??) quoted with single quotes, like:</p> <pre><code>\+ find . \+ grep -E '.*\.log$' </code></pre> <p>even though my code contains double quotes. <b>How can I prevent this?</b></p> <p>RESTRICTIONS:</p> <ul> <li>The challenge is to use both <code>find</code> and <code>grep</code>, no other cmds allowed</li> <li>Again, the challenge is to use <b>both</b>, not only <code>find</code>, as someone might want to advise</li> <li>Further info, the regular expression to be used for <code>grep</code> is much more complicated as the one shown here (several <code>OR</code> separated RegExps), I simplified it here because the annoyance happens with this one already</li> </ul> <p>I've been working on this over 4 hours without results. I've searched Google and StackOverflow but I found nothing similar. I fear that the solution is incredibly easy and I am just too stupid to find it? :-(</p> <p>Any help appreciated, thx in advance!</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload