Results 1 to 3 of 3
Hi! I am new to C Shell. I would like to write a script which able to search through a folder which might have files and many subdirectories in it. ...
- 10-03-2008 #1Just Joined!
- Join Date
- Oct 2008
- Posts
- 1
C Shell How to search through empty subdirectories?
Hi! I am new to C Shell. I would like to write a script which able to search through a folder which might have files and many subdirectories in it. How can I return value = true if the main folder having empty subdirectory? Thanks.
- 10-04-2008 #2Just Joined!
- Join Date
- Apr 2008
- Location
- Bosnia
- Posts
- 4
Hi,
Probably something like this
search=$*
if test -z "$*"
else
cd $search
# Make links in folder for every file
for f in $(find ~ | grep -i "$search" | grep -v "$(pwd)" | grep -v ".Trash" | sed s/[\ ]/{}/g)
do
file=$(echo $f | sed s/{}/\ /g ) # return spaces
link="$(date +"%H%M%S-%N")-$(basename "$file")"
ln -s "$file" "$link"
done
zenity --info --text="Done"
fi
- 10-04-2008 #3
Moving to a more appropriate forum.
I'm having difficulty following Mirza's solution, so I'm not sure that it's doing what you want.
First of all, is there a reason that you're using the C shell? It's not particularly common: most people these days use Bash, with some people moving to zsh.
Having said that, here's the basic procedure you want to follow:
Given a start directory, check its contents.
- Is it empty? Return true.
- Does it contain any directories? If not, return false.
Otherwise, add all of its directories to a queue, take the first element of the queue, make it the new start directory, and repeat.
Does that make sense?DISTRO=Arch
Registered Linux User #388732


Reply With Quote