Find knowledge base article(s) by searching for keywords in the title e.g. type linux in the search box below
Find knowledge base article(s) by browsing the subject categories of articles
Technology quick references, cheatsheets, user manuals etc.
Shop Online through ShopifyLite
Tutorials on various IT applications.
Search Title    (UL:0 |SS:f)

Software >> OS >> Unix >> Linux >> Shell >> Scripting >> How to test whether a file or directory exists in a shell script

BASH ==== for file use "if [ -f ..." for dir use "if [ -d ..." example 1 --------- #! /bin/bash if [ -f /etc/sysconfig/httpd ]; then ./etc/sysconfig/httpd fi example 2 --------- #! /bin/bash if [ -d /etc/sysconfig ] then ls /etc/sysconfig fi example 3 --------- #! /bin/bash if test -f /etc/sysconfig/httpd then ./etc/sysconfig/httpd fi
[ © 2008-2021 myfaqbase.com - A property of WPDC Consulting ]