<p>What's the "right" way to do the following as a boolean expression?</p>

<pre><code>for i in `ls $1/resources`; do
    if [ $i != "database.db" ]
    then
        if [ $i != "tiles" ]
        then
            if [ $i != "map.pdf" ]
            then
                if [ $i != "map.png" ]
                then
                    svn export -q $1/resources/$i ../MyProject/Resources/$i
...
</code></pre>

[{'answer_id': 48787, 'author': 'frizz', 'author_id': 1003, 'author_profile': 'https://Stackoverflow.com/users/1003', 'pm_score': 1, 'selected': False, 'text': '<pre><code>for i in `ls $1/resources`; do\n    if [ $i != "database.db" ] &amp;&amp; [ $i != "tiles" ] &amp;&amp; [ $i != "map.pdf" ] &amp;&amp; [ $i != "map.png" ]; then\n        svn export -q $1/resources/$i ../MyProject/Resources/$i\n</code></pre>\n'}, {'answer_id': 48793, 'author': 'Mo.', 'author_id': 1870, 'author_profile': 'https://Stackoverflow.com/users/1870', 'pm_score': 3, 'selected': False, 'text': '<p>Even shorter:</p>\n\n<pre><code>for i in `ls $1/resources`; do\n  if [ $i != databse.db -a $i != titles -a $i != map.pdf ]; then\n    svn export -q $1/resources/$i ../MyProject/Resources/$i\n  fi\ndone;\n</code></pre>\n\n<p>The <code>-a</code> in the if expression is the equivalent of the boolean AND in shell-tests. For more see <code>man test</code></p>\n'}, {'answer_id': 64106, 'author': 'pixelbeat', 'author_id': 4421, 'author_profile': 'https://Stackoverflow.com/users/4421', 'pm_score': 5, 'selected': True, 'text': '<p>The other solutions have a couple of common mistakes:\n<a href="http://www.pixelbeat.org/programming/shell_script_mistakes.html" rel="nofollow noreferrer">http://www.pixelbeat.org/programming/shell_script_mistakes.html</a></p>\n\n<ol>\n<li><p><code>for i in $(ls ...)</code> is redundant/problematic\njust do: <code>for i in $1/resources*; do ...</code></p></li>\n<li><p><code>[ $i != file1 -a $1 != file2 ]</code> This actually has 2 problems.</p>\n\n<p>a. The <code>$i</code> is not quoted, hence names with spaces will cause issues</p>\n\n<p>b. <code>-a</code> is inefficient if <code>stat</code>ing files as it doesn\'t short circuit (I know the above is not <code>stat</code>ing files).</p></li>\n</ol>\n\n<p>So instead try:</p>\n\n<pre class="lang-bsh prettyprint-override"><code>for i in $1/resources/*; do\n    if [ "$i" != "database.db" ] &amp;&amp;\n       [ "$i" != "tiles" ] &amp;&amp;\n       [ "$i" != "map.pdf" ] &amp;&amp;\n       [ "$i" != "map.png" ]; then\n        svn export -q "$i" "../MyProject/Resources/$(basename $i)"\n    fi\ndone\n</code></pre>\n'}, {'answer_id': 64247, 'author': 'Fred Yankowski', 'author_id': 7887, 'author_profile': 'https://Stackoverflow.com/users/7887', 'pm_score': 2, 'selected': False, 'text': '<p>Consider using a <strong>case</strong> statement:</p>\n\n<pre><code>for i in $(ls $1/resources); do\n    case $i in\n        database.db|tiles|map.pdf|map.png)\n           ;;\n        *)\n           svn export -q $1/resources/$i ../MyProject/Resources/$i;;\n    esac\ndone\n</code></pre>\n'}, {'answer_id': 31630150, 'author': 'Evan Langlois', 'author_id': 3847182, 'author_profile': 'https://Stackoverflow.com/users/3847182', 'pm_score': 1, 'selected': False, 'text': '<p>For future reference, the new [[ test operator is preferred.  The accepted answer is close and everything mentioned applies, but that answer will require lots of quoting and calls to multiple tests.</p>\n\n<p>The preferred method would be something like:</p>\n\n<pre><code>for i in $1/resources/*; do\n    if [[ $i != "database.db" &amp;&amp; $i != "tiles" &amp;&amp;\n                $i != "map.pdf" &amp;&amp; $i != "map.png" ]]; then\n        svn export -q "$i" "../MyProject/Resources/$(basename $i)"\n    fi\ndone\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/48774', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/79/']