linux - How to recursively do commands based on if a file exists -


I must check that a file exists in new.htaccess multiple directories (recursive) and Execute:

.htaccess rename new.htaccess .htaccess rm .htpasswd

I think the loop might work but I have a syntax Not sure about (I am a Nob for the loop).

I think it should look like this, but as I said I am a Noah and I am not getting it to do the right thing:

  For R-new.htaccess * rm .htaccess rename new.htaccess .htaccess rm .htpasswd}  

I use Red Hat linux with a Bobby v3.2.25 on Godaddy 4GH Shared Hosting

Thanks for the help!

From the initial directory, run:

  find-name "new .htaccess "-exec sh -c 'f =" {} "dir_f = $ (name of the name" $ ​​f ") new_f =" $ dir_f / .htaccess "mv -f" $ f "" $ new_f "rm -f" $ Dir_f / .htpasswd "'\;  

explanation:

  1. search -name "new.htaccess" again all "new.htaccess" files
  2. f (i.e. ./ sub / dir / new .htaccess ) for each file, dir_f (i.e / Sub / dir )
  3. Calculate the path of the new file new_f (i.e. ./ sub / dir / .htaccess )
  4. Run f above new_f ( -f means "overwrite if necessary") .
  5. Delete .htpasswd in the same folder ( -f means "do not complain if there is any .htpasswd")

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -