Results 1 to 3 of 3
Hi to all Linux Users...I have this script:
Code:
#!/bin/bash
read -p "give directory's name: " NAME
cd $NAME
count=$(ls -l | grep '\d\r\w' | wc -l)
N=1
while [ ...
- 07-04-2008 #1Just Joined!
- Join Date
- Jun 2008
- Posts
- 25
Help With a Shell Script
Hi to all Linux Users...I have this script:
But I can't get the while loop to work.I want it so that I can find how many files has each sub-directory.Thanks in advance..Code:#!/bin/bash read -p "give directory's name: " NAME cd $NAME count=$(ls -l | grep '\d\r\w' | wc -l) N=1 while [ "N" -lt "$count" ] do echo "give the name of a sub-directory" read NAME1 cd $NAME1 echo "the number of files in this sub-directory isi:" ls -1 | grep '\-\r\w' | wc -l cd .. N=$[N+1] done
- 07-04-2008 #2Just Joined!
- Join Date
- Jul 2008
- Posts
- 3
Print count and see whether you are getting any thing in it or not.
- 07-04-2008 #3Just Joined!
- Join Date
- Jun 2008
- Posts
- 25
The real problem was that I had actually forgotten to put the $ symbol before N in the while loop condition. The correct looks like this:
Code:while [ $N -lt $count ]


Reply With Quote