
09-22-2008
|
|
Shell programmer, author
|
|
|
Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
|
|
Quote:
Originally Posted by aliahsan81
Hi ALL
I am greping some thing from a file,some thing is "/var/www/html" /var/www"/example" and so on its showing like this when u use echo.
|
Please use English in this forum. Write "you", not "u".
Quote:
i want to pass each one of them in a loop for processing.Like start with /var/www/html then 2nd and so one
But that not working any iead how i give one by one value.
|
What does "not working" mean? What does happen? What do you want to happen?
Please put code inside [CODE] tags.
Quote:
Code:
docroot=$(grep -H DocumentRoot /etc/httpd/conf.d/*.conf |
awk -F' ' '{ print $3 }'| sort -u | uniq)
|
You don't need uniq; you have already removed duplicates with sort -u.
In fact, you don't need sort, either. It can be done with awk alone:
Code:
docroot=$(grep -H DocumentRoot /etc/httpd/conf.d/*.conf |
awk -F' ' '!x[$3]++ { ++n } END { print n }'
Quote:
Code:
doccount=$(grep -H DocumentRoot /etc/httpd/conf.d/*.conf |
awk -F' ' '{ print $3 }'| sort -u | uniq | wc -l)
for (( i=0; i <= $doccount; ++i ))
|
It is safer to stick to standard syntax:
Code:
i=0
while [ $i -le $doccount ]
do
: whatever
i=$(( $i + 1 ))
done
Quote:
Code:
do
confd="$docroot\n"
|
Quote:
Code:
echo $confd
find $confd -type d -perm /o=w | while read DIR
do
do some thing
done ## while done
done ##for done
|
|