How to check existence of a file using shell script?
Moderator: Staff
How to check existence of a file using shell script?
How to check existence of a file using shell script? How to check whether a file exists on the server
cPanel Server Management
@ 30$ Onwards
@ 30$ Onwards
Re: How to check existence of a file using shell script?
Example : the below script will check the file /etc/redhat-release and output whether it exists or not.
#!/bin/bash
if [ -f /etc/redhat-release ]
then
echo "file exists"
else
echo"file doesn't exist"
fi
------------------------------
Martin N
Linux Support Engineer.
Nixtree Solutions
Managed Full Server Backups
https://www.nixtree.com/managed-backups.php
Follow us on : https://twitter.com/nixtree
#!/bin/bash
if [ -f /etc/redhat-release ]
then
echo "file exists"
else
echo"file doesn't exist"
fi
------------------------------
Martin N
Linux Support Engineer.
Nixtree Solutions
Managed Full Server Backups
https://www.nixtree.com/managed-backups.php
Follow us on : https://twitter.com/nixtree