Jump to content
black_death_c4t

Shell directory dive.

Recommended Posts

Posted (edited)

are cereva idei cum pot rezolva problema asta ? :D

Sa se determine subdirectoarele , indiferent de adancime , dintr-un director dat ca parametru care contin un fisier ce ocupa mai mult de jumatate din dimensiunea subdirectorului respectiv .

nvm :) am gasit

3. Sa se determine subdirectoarele, indiferent de adancime, dintr-un director dat ca parametru care contin un fisier ce ocupa mai mult de jumatate din dimensiunea subdirectorului respectiv.
#!/bin/sh
if [ ! -d $1 ]
then
echo $1 "nu este director"
exit 1
fi
for director in `find $1 -type d`
do
# citit man ce face du
marime=`du -sk $director | cut -f 1`
marime=`expr marime / 2`
# cautam in director fisiere mai mari decat jumate din marimea directorului si daca find returneaza ceva, afisam directorul
fisier=`find $director -maxdepth 1 -size +$marime -type f`
if [ ${#fisier} -gt 0 ]
then
echo $director
fi
done

Edited by black_death_c4t

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...