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

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Check that the argument is a file

Reply to Message Icon

Name: Jose K
Date: April 30, 2005 at 00:54:22 Pacific
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



Sponsored Link
Ads by Google

Response Number 1
Name: thepubba
Date: April 30, 2005 at 11:56:53 Pacific
Reply:

#!/bin/ksh

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


0

Response Number 2
Name: Dlonra
Date: May 1, 2005 at 17:52:55 Pacific
Reply:

also,
man test


0

Response Number 3
Name: ravi.kumar
Date: May 1, 2005 at 23:48:21 Pacific
Reply:


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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Check that the argument is a file

update the contents of a file in Un www.computing.net/answers/unix/update-the-contents-of-a-file-in-un/5963.html

how to identify the size of a file www.computing.net/answers/unix/how-to-identify-the-size-of-a-file-/7523.html

shell script to check for a file on www.computing.net/answers/unix/shell-script-to-check-for-a-file-on/3714.html