forked from Musti4096/Shell_Scripting
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path004_File_Test_Operators.sh
More file actions
33 lines (27 loc) · 824 Bytes
/
004_File_Test_Operators.sh
File metadata and controls
33 lines (27 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#! /bin/bash
echo -e "Enter the name of file : \c"
read file_name
if [ -e $file_name ] # -e flasg control the file whether exist or not
# -f flag is file exist whetheer file ir regular file or not
# -d flag check for the directories
# -s flag check file whether empty or not
then
echo "$file_name already exist"
else
echo "$file_name not found"
fi
#/*/*/*/*/*/**/**/**/*/*/*/*/*/*/*/*/*****/*/*/*/*/*
echo -e "Enter the name of the file: \c"
read file_name
if [ -f $file_name ]
then
if [ -w $file_name ]
then
echo "Type some text data. To quit press ctrl+d"
cat >> $file_name
else
echo "You do not have write permission to this file"
fi
else
echo "$file_name not exist"
fi