Dear Friends:

I am new to bash programming. I been trying to write
the following two scripts for 3 days now, and I still
can't get them to worlk the way I want to. Where did I
go wrong? What's missing or what should not have been
in the script? I will be grateful to anyone who would
help me to fix these most needed scripts?

---

The first script, is in this format showExecFiles
"string". Where showExecFiles is the name of the
script and "string" a parameter. The script must
output (on the screen) all the EXECUTABLE files of the
path directories if they contain the agument string. I
also want it to clearly indicate the directory and
sub-directories being searched. 

For example: 'showExecFiles mail' to output: 

/usr/local/bin : 
---------------
/usr/local/bin/formail
/usr/local/bin/mailstat
/usr/local/bin/metamail
/usr/local/bin/procmail

/usr/bin :
---------
/usr/bin/Rnmail
/usr/bin/cmail
...
etc.


Here is my first script:
#!/bin/bash
for pathvar in `echo $PATH | sed "s/:/ /g"`;do
  echo $pathvar:
  find $pathvar -type f -name "*$1*" -maxdepth 1
done   
  
This script should be fairly easy to write. However, I
don't know how to check if the file is executable and
also how to acces sub-directories and their files.  

---

The second script, is in this format modifyXtension
"directory1" "directory2" "directory3" "..."
"directoryn". Where modifyXtension is the name of the
script and "directory1" "directory2" "directory3" etc.
any number of existing directories inside the current
directory in which we are. The script must verify
(with the program file for example) each and every
files and if it finds one or more HTML files, it must
add the suffix .html to it because many of my HTML
files do not have the right suffix. If the directory
contain sub-directories I would also like to search
these also. 

Here is my second script:
#!/bin/bash
echo Start > result
ftpe="/html"
Ext=".html"
for dir in $@;do
 for fi in `ls ./$dir`;do
  chf=1
    while [ $chf -le 8 ]
    do
      tpe=`echo $ftpe |cut -d: -f$chf`
      xts=`echo $Ext |cut -d: -f$chf`
      fls=`file -ib ./$dir/$fi | grep "$tpe"`
      test `echo $fls |wc -w` -gt 0 && cp ./$dir/$fi
`echo ./$dir/$fi |sed "s/$xts//g"`$xts
      chf=`expr $chf + 1`
  done
done
done

---

Any help will be greatly appeciated.

Peace to ALL,
FD


__________________________________________________
Do You Yahoo!?
Got something to say? Say it better with Yahoo! Video Mail 
http://mail.yahoo.com

Reply via email to