相关文章推荐
  • Check if two strings are equal?
  • Concatenate Two Strings
  • Check if string contains another string?
  • Split a string on a delimiter
  • Store command output to variable
  • Read file line by line?
  • Bash – Find factorial of a number
  • Bash – Create File Directory with Datetime
  • Bash – Check If Directory Exists
  • Bash – Check If A File Exists
  • Examples
  • Bash – Check If Directory Exists
  • Bash – Check If Directory Exists

    Bash Program to Check if A Directory Exists

    Q. How do I check if a directory exists or not?

    Add the following code to a shell script to verify if defined directory exists. Then execute a set of statement if directory exists:

    • Check if a directory exists:
    • Check if a directory doesn’t exist:

    Example

    A sample shell script to navigate to a specific directory only if exists.

     
    推荐文章