Find the answer to your Linux question:
Results 1 to 3 of 3
So, I need to find if, in a folder any directories exist, except a certain one named "mes croquis". What I am trying to say, is that the re already ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2009
    Posts
    6

    [SOLVED] How to check if any directories exist, except a certain one ?


    So, I need to find if, in a folder any directories exist, except a certain one named "mes croquis".
    What I am trying to say, is that the re already is a directory named "my croquis", which I have to ignore. IF any other directory appears, I have to archive them.
    I got everything so far, except the starting condition.
    In other terms , I am lookign for something like this:

    IF anyDir EXIST AND name != "mes croquis"
    do something
    else
    exit


    or
    IF THE ONLY EXISTING DIR IS "mes croquis" then EXIT

    I am kinda puzzled by this, I tried various combinations of [-d something ], find but nothing quite does it.

    Any ideas ?

    thanks in advance,
    rmcb

  2. #2
    Just Joined!
    Join Date
    Jan 2009
    Posts
    6

    Unhappy

    This is what I've got so far that is closest to something functional:

    Code:
    source="/home/roderick/Bureau/"
    anyDirs=`find $source* -maxdepth 1 -type d -not -name 'mes croquis'` 
    
    if [ -n "$anyDirs" ]; then 
    	echo no dirs exit now 
    else 
    	echo go ahead 
    fi
    Nevertheless, it still does not work.

  3. #3
    Just Joined!
    Join Date
    Jan 2009
    Posts
    6
    Ok, I got it working now:

    Code:
    [ -s `find $source* -maxdepth 1 -type d -not -name 'mes croquis'`  ] && exit

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •