nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

Script to remove executable files

This is a discussion on Script to remove executable files within the Shell scripting forums, part of the Development/Scripting category; Hi We have /home/project/dir1 dir2 and so on of our project files. Some time we don’t need the executable files ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 02-23-2005, 02:25 PM
sweta's Avatar
Contributors
User
 
Join Date: Feb 2005
Location: New Delhi
My distro: Suse, RHEL, Vista
Posts: 154
Rep Power: 4
sweta will become famous soon enough
Default Script to remove executable files

Hi

We have /home/project/dir1 dir2 and so on of our project files. Some time we don’t need the executable files how to remove them using script. I know it can be done with Make file but I’m looking for script any hit is appreciated

OS are FreeBSD and Linux

Thanks in advance
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-24-2005, 11:51 AM
monk's Avatar
Senior Member
User
 
Join Date: Jan 2005
Location: Tibet
My distro: Debian GNU/Linux
Posts: 482
Rep Power: 5
monk will become famous soon enough monk will become famous soon enough
Default

Sorry but i'm not getting you... what u r trying to do ?
Reply With Quote
  #3 (permalink)  
Old 02-24-2005, 05:09 PM
Guest
 
Posts: n/a
Default

May be try
Code:
files * | grep ELF | cut -d: -f1 |xargs rm -f
Reply With Quote
  #4 (permalink)  
Old 03-07-2005, 08:22 AM
Junior Member
User
 
Join Date: Feb 2005
Posts: 8
Rep Power: 0
ryan
Send a message via MSN to ryan
Default

I cannot give extra clear command, but I thing following step should a resolution :

1.find the files which have exe attribute under /home/project
2.del the files , could get them from piple.
Reply With Quote
  #5 (permalink)  
Old 03-12-2005, 02:21 PM
Junior Member
User
 
Join Date: Feb 2005
Location: Punjab
Posts: 6
Rep Power: 0
Gopal
Default solution

Hi,

try these lines

Code:
#!/bin/bash
for name in `tree -ifp | grep "\[-..x" | tr -s " " | cut -d " " -f2`
do
rm $name
done
Quote:
tree -ifp
will give you list of all dirs recursively including all subdirectories with FAP and relative pathname

Quote:
grep "\[-..x"
will fetch only executable files from FAP with relative pathname

Quote:
tr -s " "
will squeeze the space between the two columns i.e. FAP and path to file.

Quote:
cut -d " " -f2
will fetch the second column i.e. relative path and filename.

these filenames with relative pathname are saved in
Quote:
name
variable and then the
Quote:
rm
command removes those file.

Try and see..

Gopal
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
convert perl code into binary executable chandanperl Coding in General 0 03-13-2008 11:43 AM
Shell script for automatic conversion of files in tar files kasimani Shell scripting 2 02-08-2007 04:45 PM
Executable file in Awstats RPM! honey bee Linux software 2 03-29-2006 06:11 PM
Grep and remove files Linux software 1 01-05-2006 07:25 PM
script for uploading files to a FTP server marinm Shell scripting 7 01-02-2006 08:35 PM


All times are GMT +5.5. The time now is 08:58 PM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36