2 Following Script Bin Bash F D F Echo F Fi Done Q37253900

2. What does the following script do?

#!/bin/bash

for f in *

do

if [ -d “$f” ]

     then

        echo “$f”

     fi

done


Answer


It will print all the directory name in the system

-d for directory that filters the directory name

4 6 8 9 10 |#!/bin/bash 12 for f in * 13 14 do 15 16 if [ -d $f ] 17 18 19 20 21 then echo $f fi 23 24 done Run it (F8)ve

If you want to print all the file name then

ーEditor CodeMirror Language: Bash #1 /bin/bash 10 12 for f in* 14 do 15 16 if [ -f $f ] 17 18 then echo $f 20 21 fi 24 do

θ] 123 161 animation.gif rchive a.txt charges.txt con.txt data.txt exclude.list f1.txt file.txt krtik myfile.txt myscript new

Thanks

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.