I have the following two files in my working directory:
test.txt
and img.jpg
test.txt
is a character special file
img.jpg
is a block special file
Now I want to find if these files are character special files or block special files using shell script.
I have written the following two shell scripts:
First-
#! /bin/bash
echo -e "Enter file name: \c"
read file_name
if [ -c $file_name ]
then
echo Character special file $file_name found
else
echo Character special file $file_name not found
Input:
test.txt
Output:
Character special file test.txt not found
Second-
#! /bin/bash
echo -e "Enter file name: \c"
read file_name
if [ -b $file_name ]
then
echo Block special file $file_name found
else
echo Block special file $file_name not found
Input:
img.jpg
Output:
Block special file img.jpg not found
Where am I going wrong?