In folder A i have a file "a' and text file named infile00.I would like to do redirection :a<infile01.
There is a code to do this
#get a file "a" in /home/A
for file in `ls /home/A`
do
if [ -x file ]
then
#printing out if file is an execute file
echo $file "is an execute file"
# get an input file named input00 in /home/A
for input in `ls /home/A`
do
if [ ! -x input ]
then
home/A/$file<input
fi
done
fi
done
When i executed the script above, output was
correct is an execute
infile00 is an execute
I tried to correct the problem but.....the result did not change at all (even got worse)
Can anyone help me out.
What does it (i.e) "${file#/home/A/}" actually do? I tried with my home directory, but the variable 'file' shows empty.
What is the meaning of 'prune it off'?
#!/bin/ksh
# Get an executable file in $*
list_dir=$(ls $*)
for file in $list_dir
do
if [ -x $file ]
then
#printing out if file is an execute file
echo "File $file is an execute file"
# get a non-executable input file in $1
for zfile in $list_dir
do
if [ ! -x $zfile ]
then
echo "File $zfile is a data file"
$file < $zfile
fi
done
fi
done
File 'a' (executable)
#!/bin/ksh
echo "Hello, I'm the 'a' file !"
echo "Here is my input:"
while read n
do
echo $n
done
echo "End of file 'a'"
File 'input00' (non executable)
- this
- is
- the
- input
- of
- the
- file
- intput00
File 'input01' (non executable)
- this
- is
- the
- input
- of
- the
- file
- intput01
Execute:
./cmd A/*
File A/a is an execute file
File A/input00 is a data file
Hello, I'm the 'a' file !
Here is my input:
- this
- is
- the
- input
- of
- the
- file
- intput00
End of file 'a'
File A/input01 is a data file
Hello, I'm the 'a' file !
Here is my input:
- this
- is
- the
- input
- of
- the
- file
- intput01
End of file 'a'