Quantcast
Channel: Unix Scripting – wikiconsole
Viewing all articles
Browse latest Browse all 10

Unix Shell Scripts – Example 4

$
0
0

Write a shell script that takes a name of a folder as a command line argument, and produce a file that contains the names of all sub folders with size 0 (that is empty sub folders)

 

#! /bin/sh
ls $1 |
while read folder
do
     if [ -d $1/$folder ]
     then
       files=ls $1/$folder | wc –l
       if [ $files –eq 0 ]
          then
                echo $folder >> output.txt
       fi
     fi
done


Viewing all articles
Browse latest Browse all 10

Trending Articles