Computing.Net > Forums > Unix > Check that the argument is a file

Check that the argument is a file

Reply to Message Icon

Original Message
Name: Jose K
Date: April 30, 2005 at 00:54:22 Pacific
Subject: Check that the argument is a file
OS: Red Hat 9
CPU/Ram: 256
Comment:

Hi

In Shell Script, how do I check that the argument is a file?

Thanks in advance

Jose


Report Offensive Message For Removal

Response Number 1
Name: thepubba
Date: April 30, 2005 at 11:56:53 Pacific
Subject: Check that the argument is a file
Reply: (edit)

#!/bin/ksh

if [[ -f $1 ]]
then
print "It's a file"
else
print "It ain't"
fi


Report Offensive Follow Up For Removal

Response Number 2
Name: Dlonra
Date: May 1, 2005 at 17:52:55 Pacific
Subject: Check that the argument is a file
Reply: (edit)

also,
man test


Report Offensive Follow Up For Removal

Response Number 3
Name: ravi.kumar
Date: May 1, 2005 at 23:48:21 Pacific
Subject: Check that the argument is a file
Reply: (edit)


if(-f $1)
then
echo " $1 is file"
else
echo " $1 is not a file"
fi

Hello I am working extensively on SCM and Unix


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Check that the argument is a file

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software