1 Replies - 1880 Views - Last Post: 02 February 2009 - 03:49 AM

#1 ericode   User is offline

  • D.I.C Head
  • member icon

Reputation: 7
  • View blog
  • Posts: 112
  • Joined: 09-December 06

list all executable files in your $PATH

Posted 18 December 2007 - 09:26 PM

Description: Perl script with some bash scripting that lists all the executable files in each of the directories in your $PATH environmental variable in bash. Also searches the current directory.
#!/usr/bin/perl
#purpose: to display all the executable files in all the directories in your $PATH

#get the $PATH environmental variable that you would have in bash,
#here I assign it to a variable in perl of the same name, $PATH
$PATH=`echo $PATH`;

#now store an array of directory names that are in $PATH, the :
#character separates each name
@a_directory_names = split(/:/, $PATH);

#found this following command to list only executable files in a directory at this web address:
#http://groups.google.com/group/alt.os.linux/browse_thread/thread/65c9f77609827be6/c224918c535b1d8e%23c224918c535b1d8e
#find /dir -perm +111 -maxdepth 1 -type f

$size = @a_directory_names;
# iterate over array
for ($i=0; $i<$size; $i++)
{
        print `find /$a_directory_names[$i] -perm +111 -maxdepth 1 -type f`;
}

#and since I don't have the current directory in my path, I'll print executable files in it separately
print `find ./ -perm +111 -maxdepth 1 -type f`;



Is This A Good Question/Topic? 0
  • +

Replies To: list all executable files in your $PATH

#2 Poornima Mani   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 178
  • Joined: 25-January 09

Re: list all executable files in your $PATH

Posted 02 February 2009 - 03:49 AM


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1