slashwannabe94
August 13th, 2011, 09:21 PM
Hello all, i know this may be a stupid question but i can't get my head around it.
I was writing a script to list files, subdirectories, files with zero length and the disk storage used in my home directory. I was given this code by someone on the forums. It works and does what i want it to do. But their is no point in using code that i don't understand. I have no clue what is going on when it runs.
I understand the lines highlighted in red. But nothing else.
files=()
while IFS= read -d '' -r file
do
files+=("$file")
done< <(find ./ -maxdepth 1 -type f -print0)
echo "The number of files in the current directory = ${#files[@]}"
echo -n "The number of subdirectories = "
ls -a -I .. -1 --file-type --group-directories-first | grep / | wc -l
echo -n "The number of files with zero length = "
find . -maxdepth 1 -type f -size 0c | wc -l
echo -n "The amount of disk storage used by this directory = "
du -h -c /home/static | tail -n 1
Any help is much appreciated. Thanks guys,
SlashWannabe94
I was writing a script to list files, subdirectories, files with zero length and the disk storage used in my home directory. I was given this code by someone on the forums. It works and does what i want it to do. But their is no point in using code that i don't understand. I have no clue what is going on when it runs.
I understand the lines highlighted in red. But nothing else.
files=()
while IFS= read -d '' -r file
do
files+=("$file")
done< <(find ./ -maxdepth 1 -type f -print0)
echo "The number of files in the current directory = ${#files[@]}"
echo -n "The number of subdirectories = "
ls -a -I .. -1 --file-type --group-directories-first | grep / | wc -l
echo -n "The number of files with zero length = "
find . -maxdepth 1 -type f -size 0c | wc -l
echo -n "The amount of disk storage used by this directory = "
du -h -c /home/static | tail -n 1
Any help is much appreciated. Thanks guys,
SlashWannabe94