Re: [LIP] want to test presence of file
Chandrashekar Babu <[email protected]>
| Newsgroups | gmane.user-groups.linux.india.programmers |
|---|---|
| Organization | http://www.chandrashekar.info/ |
| Message-ID | <[email protected]> |
> I am making a command line tool which accept a argument that is a file name....
> I want to check whether the file present or not (How can I check in
> Shell programming?)
Method 1:
#!/bin/sh
if test -e $1
then
echo "$1 exists."
else
echo "$1 does not exist."
fi
Method 2:
#!/bin/sh
[ -e $1 ] && echo "$1 exists" || echo "$1 does not exist"
To know more, 'man test'.
--
Chandrashekar Babu
http://www.chandrashekar.info/
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click