check whether a file exists or not ??
Hi all,
Is there any simple command to find out whether file exists or not ? Somewhat there is for checking a folder, for eg checking a folder /tmp/vikas Code:
if [ -d /tmp/vikas/passwd/$a ]; VIKAS |
Enter "help test" in bash. There are 19 more tests you can use a well.
|
Thanks, didnt knew it was so simple.
I was counting chars of output and deciding whether a file/folder exists or not. How stupid :eek: Code:
bash # ls -l /etc/passwd | wc -c Didnt knew it was so simple. Thanks a ton. |
Anyways, this is only for bash shell.
Do we have something universal for all shells ? Regards, Vikas |
test also exists as an external command, probably in /usr/bin/test. It has a man page and info manual.
This is similar to "[" which is a built-in but also exists as a regular command, something required by the Posix standard. |
Quote:
Ok, I thought that it works on bash shell only. I have checked it on another shells also. Thanks friend ! |
All times are GMT -5. The time now is 04:49 PM. |