Note that there are some explanatory texts on larger screens.

plurals
  1. POUnix Shell Scripting - Loop until files are not found
    primarykey
    data
    text
    <p>I am writing shell script. I need to check specific directory for files existence with 2 specific file extension "eob" and "inp", and if exists I want to stay in the loop and keep on checking until files do not exist, then I want to break from my loop and proceed with the rest of the logic.</p> <p>Below is the code I have so far, but it is not working...</p> <pre><code>while true do [ ! find /home/mpcmi/cm -type f \( -name "*.eob" -o -name "*.inp" \) ] &amp;&amp; break echo "eob or inp file exists" sleep 2 done echo "eob or inp file doesn't exists" </code></pre> <p>First, I am getting this error when running the script:</p> <pre><code>"/home/mpcmi/cm: unknown test operator" </code></pre> <p>Second, it checks and finds the files with these extensions correctly I suppose because I am getting the output: "eob or inp file exists" however when I delete my test "eob" and "inp" files the script doesn't seem to detect it, it stops printing "eob or inp file exists" but it never prints "eob or inp file doesn't exists" </p> <p>Below is the entire output, then it just stops after I delete test "eob" and "inp" files:</p> <pre><code>employees_load.sh[9]: /home/mpcmi/cm: unknown test operator eob or inp file exists employees_load.sh[9]: /home/mpcmi/cm: unknown test operator eob or inp file exists employees_load.sh[9]: /home/mpcmi/cm: unknown test operator eob or inp file exists employees_load.sh[9]: /home/mpcmi/cm: unknown test operator eob or inp file exists employees_load.sh[9]: /home/mpcmi/cm: unknown test operator eob or inp file exists employees_load.sh[9]: /home/mpcmi/cm: unknown test operator eob or inp file exists employees_load.sh[9]: /home/mpcmi/cm: unknown test operator eob or inp file exists </code></pre> <p>Can someone help?</p> <p>Thanks!</p>
    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