Linux Fo Rloop Used Iterate Current Directory Check File Permissions Print Files Execute P Q37108365

LINUX

  1. The fo rloop can be used to iterate through the currentdirectory to check file permissions.  To print all fileswith execute permission:

#!/bin/bash
for i in *; do

     if [ -x $i ];then

          echo$i

                          fi

done

  1. Writeanewscript,script7.shthatincludes the above code.  9) What printsout?  Modify the script to print out all files withwrite permission.  10) What flag did you use to checkthat a file has write permission?

  1. 11) Include a copy this script in youranswerfile.

Solution


9)

Please find the required program along with the output:

script7.sh

————–

#!/bin/bash
for i in *; do
if [ -x $i ]; then
echo $i
fi
done

OUTPUT:

rishi@ubuntu:/chegg$ rishi@ubuntu:~/chegg$ ll total 28 drwxr-xr-x 2 rishi rishi 4096 Apr 19 12:37/ drwxr-xr-x 17 rishi rishi

10)

OR
OR

Leave a Comment

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