linux - Select specific Directory among many Directories -


I am trying to write a shell script that contains thresholds through all the directories under the root directory and containing empty folders Skip the directory "I_AM_Already_Processed" at the leaf level.

The original directory is provided as an input for shell script:

  Structure under the parent directory is shown below (data in the employee directory annually Is divided - Monthly - & gt; Daily - & gt; hourly basis)   former>  / employee / alert / output / 2014 / 10/08 / hour / actual_file < / code>  

Shell script is trying to figure out which Complaints and s already processed. For example:

Let us consider the three hour data of the date: 10/08/2014

  1 / USD / alert / output / 2014/10 / 08/2 (Hourly_Nirectory) / real_file + directory_name_ (I_AM_Already_Processed) 2. / US Dollar / Alert / Output / 2014 / 10/08/3 (Hourly_book directory) / Actual_file + directory_with_name (I_AM_Already_Processed) 3. / USD / Alert / Output / 2014 / 10/08 / (horary_directory) / Actual_file   

Leaf Directory 2 and 3 were already processed in the above example Because they are called "I_AM_Already_Processed folder" and when Directory 4 has not already been processed.

Therefore the shell script should be left folders 2, 3, but should work on directory 4 (print this directory in the output).

I have done research / work:

Now I can iterate through the directory structure and want to move all the folders / files from root to level level, but I'm not sure how to check the specific file and leave the directory if that file exists. (I was able to do a lot of tutorials on Stack Overflow and after the context of old posts)

I'm a newbie for shell scripting, this is my first time writing a shell script, so if it's too much Please forgive me for asking basic questions. trying to learn.

Any suggestions welcome are welcome in advance.

To check that any some_directory has already been processed , Just do something like

  find some directory-type d -links 2 -name 'I_AM_Already_Processed'   

if it is not. Note links 2 test If the directory is a leaf (which means that only its parents have links, but not for any subdirectory) see for more information.

Then in a script, you can

  #! / Bin / bash directory_list = (/ dir1 / dir2) "$ {directory_list [@]}"; If [[-n $ ("$ dir" type d -links2 -name 'I_AM_Already_Processed' -print -quit)]]; Then the echo has been 'processed' and the second echo 'has not been processed' fi    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -