If Conditons for a | FILE related

 In shell scripting, various file-related conditions can be used to check the properties of files. Here are some common file-related conditions in Bash scripting:

  1. Existence Checks:

    • -e file: True if file exists.
    • -f file: True if file exists and is a regular file.
    • -d file: True if file exists and is a directory.
    • -s file: True if file exists and has a size greater than zero.
  2. Permission Checks:

    • -r file: True if file exists and is readable.
    • -w file: True if file exists and is writable.
    • -x file: True if file exists and is executable.
  3. Ownership Checks:

    • -O file: True if file exists and is owned by the current user.
    • -G file: True if file exists and is owned by the current group.
  4. Modification Time Checks:

    • -nt file: True if the current file is newer than file.
    • -ot file: True if the current file is older than file.
  5. Type Checks:

    • -h file: True if file exists and is a symbolic link.
    • -L file: Same as -h.
    • -p file: True if file exists and is a named pipe (FIFO).
    • -S file: True if file exists and is a socket.
    • -b file: True if file exists and is a block special file.
    • -c file: True if file exists and is a character special file.

These conditions can be used in various contexts, including if statements, loops, and command-line operations, to determine the attributes of files and directories. Here's an example of how you might use some of these conditions:

Comments

Popular posts from this blog

AWK : Commands

CURL Commands

$$$$ Symbols in shell scripting