|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
shell scripting problem
need to know how to answer the following problem,i have a version but im getting errors i can't seem to fix,any help will be appreciated:
iam required to list all executeable files in a specified directory.the scipt works as follows ./exexcFiles[directory][file] if no file is specified then result is displayed to the screen.if a file is specifired the results are sent to it.errror messages are to be included also. my version so far is: clear currentDir = $PWD if [$# -gt 0 -a $# -lt 2]; then echo "you need to enter an argument" elif [test -d $1]; then cd $1 touch newFile for i in * do if -x $i -a -f $i echo -e "$i" mv "$i"/"$newfile" done if [$# -eq 2]; then echo "a file name has been entered" touch $2 mv "newFile"/"$2" mv "$2"/"$currentDir" fi |
|
#2
|
|||
|
|||
|
RE: shell scripting problem
how about this script
Code:
#!/bin/bash if [ "" == "$1" -o "-?" == "$1" ] then echo "usage:" echo " `basename $0` dirname filename" exit fi if [ "" != "$2" ] then # redirect all output to $2 exec 2>&1 >$2 fi for f in `find $1 -perm +111 -maxdepth 1 -type f` do basename $f done |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Server Administration > shell scripting problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|