13 Exp Print

Download as odt, pdf, or txt
Download as odt, pdf, or txt
You are on page 1of 4

#!

/bin/bash
#code to check file is readable or not
echo "Enter file name to check it is readable or not"
read s
if [ -r "$s" ];then
echo "File is readable"
else
echo "File is not readable"
fi

#!/bin/bash
#code to check file exits and greater than zero or not
echo "Enter file name to check it exists and it has size greater than zero"
read k
if [ -s "$k" ];then
echo "File exits and it has size greater than zero"
else
echo "File does notvexits and it does not have size greater than zero"
fi

#!/bin/bash
#code to check file is execuable or not
echo "Enter file name to check it is executable or not"
read l
if [ -x "$l" ];then
echo "File is executable"
else
echo "File is not executable"
fi

#!/bin/bash
#code to check file is writable or not
echo "Enter file name to check it is writable or not"
read m
if [ -w "$m" ];then
echo "File is writable"
else
echo "File is not writable"
fi
atharv@atharv-Vostro-2520:~$ ls -l
total 220
-rw-rw-r-- 1 atharv atharv 162 Dec 10 13:50 13a.sh
-rw-rw-r-- 1 atharv atharv 6 Dec 5 19:56 1.txt
-rw-rw-r-- 1 atharv atharv 16 Dec 5 09:05 2.txt
-rw-rw-r-- 1 atharv atharv 141 Dec 5 06:42 acz.txt
-rw-rw-r-- 1 atharv atharv 52 Dec 5 09:08 ai.txt
-rw-rw-r-- 1 atharv atharv 21 Dec 5 09:07 ao.txt
drwxrwxr-x 2 atharv atharv 4096 Dec 5 09:21 ap
-rw-rw-r-- 1 atharv atharv 9 Dec 9 17:18 apc.txt
-rw-rw-r-- 1 atharv atharv 18 Dec 9 17:16 ap.txt
-rw-rw-r-- 1 atharv atharv 20 Dec 5 09:27 ath11.txt
-rw-rw-r-- 1 atharv atharv 8 Dec 9 17:14 ath1.txt
-rw-rw-r-- 1 atharv atharv 18 Dec 5 06:29 ath2.txt
-rw-rw-r-- 1 atharv atharv 7 Dec 9 17:14 atharv.txt
-rw-rw-r-- 1 atharv atharv 33 Dec 5 09:45 athh.txt
-rwxrwxrwx 1 atharv atharv 18 Dec 9 01:47 ath.txt
-rw-rw-r-- 1 atharv atharv 33 Dec 9 17:22 attt.txt
-rw-rw-r-- 1 atharv atharv 7 Dec 9 17:20 at.txt
-rw-rw-r-- 1 atharv atharv 27 Dec 5 09:47 a.tx
-rw-rw-r-- 1 atharv atharv 25 Dec 9 17:24 b.txt
-rw-rw-r-- 1 atharv atharv 130 Dec 5 08:58 bx.txt
-rw-rw-r-- 1 atharv atharv 25 Dec 9 01:47 qth.txt
-rw-rw-r-- 1 atharv atharv 36 Dec 5 06:32 q.txt
-rw-rw-r-- 1 atharv atharv 4 Dec 5 09:34 s1.txt
-rw-rw-r-- 1 atharv atharv 60 Dec 5 09:35 s2.txt
-rw-rw-r-- 1 atharv atharv 1127 Dec 10 01:26 sa.txt
-rw-rw-r-- 1 atharv atharv 36 Dec 5 20:02 sd1.ttxt
-rw-rw-r-- 1 atharv atharv 27 Dec 5 20:03 sd1.txt
drwxr-xr-x 2 atharv atharv 4096 Dec 5 02:00 Templates
-rw-rw-r-- 1 atharv atharv 191 Dec 5 08:58 todo.txt
-rw-rw-r-- 1 atharv atharv 39 Dec 5 09:14 t.txt
-rw-rw-r-- 1 atharv atharv 141 Dec 5 06:43 u.txt
drwxr-xr-x 2 atharv atharv 4096 Dec 5 02:00 Videos
-rw-rw-r-- 1 atharv atharv 12 Dec 5 08:52 xaa
-rw-rw-r-- 1 atharv atharv 11 Dec 5 08:52 xab
-rw-rw-r-- 1 atharv atharv 12 Dec 5 08:52 xac
-rw-rw-r-- 1 atharv atharv 12 Dec 5 09:14 x.txt
-rw-rw-r-- 1 atharv atharv 12 Dec 5 09:56 z.txt
atharv@atharv-Vostro-2520:~$ chmod 777 13a.sh
atharv@atharv-Vostro-2520:~$ ./13a.sh
-s Enter file name to check it is readable or not
q.txt
./13a.sh: line 8: syntax error near unexpected token `done'
./13a.sh: line 8: `done'
atharv@atharv-Vostro-2520:~$ ./13a.sh
Enter file name to check it is readable or not
q.txt
./13a.sh: line 8: syntax error near unexpected token `done'
./13a.sh: line 8: `done'
atharv@atharv-Vostro-2520:~$ ./13a.sh
Enter file name to check it is readable or not
q.txt
File is readable
atharv@atharv-Vostro-2520:~$ chmod 777 13b.sh
atharv@atharv-Vostro-2520:~$ ./13b.sh
Enter file name to check it exists and it has size greater than zero
q.txt
File exits and it has size greater than zero
atharv@atharv-Vostro-2520:~$ ls -l
total 224
-rwxrwxrwx 1 atharv atharv 158 Dec 10 13:51 13a.sh
-rwxrwxrwx 1 atharv atharv 251 Dec 10 13:55 13b.sh
-rw-rw-r-- 1 atharv atharv 6 Dec 5 19:56 1.txt
-rw-rw-r-- 1 atharv atharv 16 Dec 5 09:05 2.txt
-rw-rw-r-- 1 atharv atharv 141 Dec 5 06:42 acz.txt
-rw-rw-r-- 1 atharv atharv 52 Dec 5 09:08 ai.txt
-rw-rw-r-- 1 atharv atharv 21 Dec 5 09:07 ao.txt
drwxrwxr-x 2 atharv atharv 4096 Dec 5 09:21 ap
-rw-rw-r-- 1 atharv atharv 9 Dec 9 17:18 apc.txt
-rw-rw-r-- 1 atharv atharv 18 Dec 9 17:16 ap.txt
-rw-rw-r-- 1 atharv atharv 20 Dec 5 09:27 ath11.txt
-rw-rw-r-- 1 atharv atharv 8 Dec 9 17:14 ath1.txt
-rw-rw-r-- 1 atharv atharv 18 Dec 5 06:29 ath2.txt
-rw-rw-r-- 1 atharv atharv 7 Dec 9 17:14 atharv.txt
-rw-rw-r-- 1 atharv atharv 33 Dec 5 09:45 athh.txt
-rwxrwxrwx 1 atharv atharv 18 Dec 9 01:47 ath.txt
-rw-rw-r-- 1 atharv atharv 33 Dec 9 17:22 attt.txt
-rw-rw-r-- 1 atharv atharv 7 Dec 9 17:20 at.txt
-rw-rw-r-- 1 atharv atharv 27 Dec 5 09:47 a.txt
-rw-rw-r-- 1 atharv atharv 61 Dec 5 08:56 ax.txt
drwxrwxr-x 2 atharv atharv 4096 Dec 5 09:00 bsiet
-rw-rw-r-- 1 atharv atharv 25 Dec 9 17:24 b.txt
-rw-rw-r-- 1 atharv atharv 130 Dec 5 08:58 bx.txt
drwxrwxr-x 2 atharv atharv 4096 Dec 5 09:00 CM5I
drwxr-xr-x 3 atharv atharv 4096 Dec 9 02:13 Desktop
drwxr-xr-x 2 atharv atharv 4096 Dec 10 13:33 Documents
drwxr-xr-x 2 atharv atharv 4096 Dec 5 02:00 Downloads
-rw-rw-r-- 1 atharv atharv 12288 Dec 5 06:57 exp6.txt
-rw-rw-r-- 1 atharv atharv 17 Dec 5 19:58 m.txt
drwxr-xr-x 2 atharv atharv 4096 Dec 5 02:00 Music
-rw-rw-r-- 1 atharv atharv 6 Dec 5 09:50 n.txt
-rw-rw-r-- 1 atharv atharv 18 Dec 5 20:35 o.txt
drwxr-xr-x 2 atharv atharv 4096 Dec 10 01:26 Pictures
-rw-rw-r-- 1 atharv atharv 8 Dec 9 17:19 po.txt
-rw-rw-r-- 1 atharv atharv 35 Dec 5 06:31 p.txt Videos
-rw-rw-r-- 1 atharv atharv 12 Dec 5 08:52 xaa
-rw-rw-r-- 1 atharv atharv 11 Dec 5 08:52 xab
-rw-rw-r-- 1 atharv atharv 12 Dec 5 08:52 xac
-rw-rw-r-- 1 atharv atharv 12 Dec 5 09:14 x.txt
-rw-rw-r-- 1 atharv atharv 12 Dec 5 09:56 z.txt
atharv@atharv-Vostro-2520:~$ ./13b.sh
Enter file name to check it exists and it has size greater than zero
todo.txt
File exits and it has size greater than zero
atharv@atharv-Vostro-2520:~$ chmod 777 13c.sh
atharv@atharv-Vostro-2520:~$ ./13c.sh
Enter file name to check it is executable or not
q.txt
File is not executable
atharv@atharv-Vostro-2520:~$ ls -l
total 228
-rwxrwxrwx 1 atharv atharv 158 Dec 10 13:51 13a.sh
-rwxrwxrwx 1 atharv atharv 251 Dec 10 13:55 13b.sh
-rwxrwxrwx 1 atharv atharv 164 Dec 10 13:58 13c.sh
-rw-rw-r-- 1 atharv atharv 6 Dec 5 19:56 1.txt
-rw-rw-r-- 1 atharv atharv 16 Dec 5 09:05 2.txt
-rw-rw-r-- 1 atharv atharv 141 Dec 5 06:42 acz.txt
-rw-rw-r-- 1 atharv atharv 52 Dec 5 09:08 ai.txt
-rw-rw-r-- 1 atharv atharv 21 Dec 5 09:07 ao.txt
drwxrwxr-x 2 atharv atharv 4096 Dec 5 09:21 ap
-rw-rw-r-- 1 atharv atharv 9 Dec 9 17:18 apc.txt
-rw-rw-r-- 1 atharv atharv 18 Dec 9 17:16 ap.txt
-rw-rw-r-- 1 atharv atharv 20 Dec 5 09:27 ath11.txt
-rw-rw-r-- 1 atharv atharv 8 Dec 9 17:14 ath1.txt
-rw-rw-r-- 1 atharv atharv 18 Dec 5 06:29 ath2.txt
-rw-rw-r-- 1 atharv atharv 7 Dec 9 17:14 atharv.txt
-rw-rw-r-- 1 atharv atharv 191 Dec 5 08:58 todo.txt
-rw-rw-r-- 1 atharv atharv 39 Dec 5 09:14 t.txt
-rw-rw-r-- 1 atharv atharv 141 Dec 5 06:43 u.txt
drwxr-xr-x 2 atharv atharv 4096 Dec 5 02:00 Videos
-rw-rw-r-- 1 atharv atharv 12 Dec 5 08:52 xaa
-rw-rw-r-- 1 atharv atharv 11 Dec 5 08:52 xab

-rw-rw-r-- 1 atharv atharv 12 Dec 5 09:56 z.txt


atharv@atharv-Vostro-2520:~$ ./13c.sh
Enter file name to check it is executable or not
bsiet
File is executable
atharv@atharv-Vostro-2520:~$ chmod 777 13d.sh
atharv@atharv-Vostro-2520:~$ ./13d.sh
Enter file name to check it is writable or not
q.txt
File is writable

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy