Script help needed with file command and such
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Shell > Script help needed with file command and such




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Script help needed with file command and such  
James Nykiel


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-09-04 01:47 AM

Greetings:


I would like to create a BASH script that is able to drill down through a
directory and its subdirectories, identify all the files that are binary
and perform a chmod on them on the fly.

I think the file command is what I need to use to identify the binary
files, what I am not sure about is how to drill down the directory
structure and supply the listing of each directory to the file command for
for processing.


Thanks - Jim






[ Post a follow-up to this message ]



Muthukumar_K is offline     Re: Script help needed with file command and such  
Muthukumar_K


View Ip Address Report This Message To A Moderator Edit/Delete Message


Click Here to See the Profile for Muthukumar_K Click here to Send Muthukumar_K a Private Message Visit Muthukumar_K's homepage! Find more posts by Muthukumar_K Add Muthukumar_K to your buddy list
 
10-13-04 03:43 PM

We can simulate binary executable files using find + file command as,

 
 for file in `find / -type f -name "*"`
 do

    if [[ $(file $file | grep -q 'executable') -eq 0 ]]
    then

      # File is executable
      chmod <mod> $file

   fi

 done

 If you want combine few pattern with executable then add as,
 
 $(file $file | grep -q 'executable' | grep -q 'ELF') -eq 0

 there.


HTH.

Regards
Muthukumar


__________________
========================================

Muthukumar Kandasamy

Home Page: http://geocities.com/kmuthu_gct/
Mail: zenmuthu@gmail.com / kmuthu_gct@yahoo.com
Phone: +91-94436 62936
========================================



[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 12:29 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register