Let’s say you are creating a batch script to loop through each “folder” you have in an directory- run:
$./list_dirs.sh /app
inside the shell script:
#list_dirs.sh
for i in $(ls -l $1 | awk ‘/^d/ { print $NF }’) ; do
echo $i # replace with actions to be done
done
#end script
basically ls -l will display all files+folders with their attributes.
awk filters to those lines starting with d attribute (/!d/) and strips out to the last field ($NF)
blog>logout


Recent Comments