Script Course

From rbachwiki
Revision as of 00:37, 13 March 2019 by Bacchas (talk | contribs)
Jump to navigation Jump to search

File Operators Tests

Escape Sequence
Test Statements
  • -d File True if file is a directory
  • -e File True if file exists
  • -f File True if file exists and is a regular file
  • -r File True if file is readable by you
  • -s File True if file exist and is not empty
  • -w File True if the file is writable by you
  • -x File True if the file is executable by you
  • -z String True if string is empty
  • -n String true if string is not empty

Syntax

[condition to test for]

Example

[ -e /etc/passwd ]
-e True if file exists

$? Contains the return code of the previously executed command

Bash menu- Home