Complete the code to check if the file 'data.txt' exists.
if [ [1] "data.txt" ]; then echo "File exists" fi
The -e option checks if a file or directory exists.
Complete the code to check if 'log.txt' is a regular file.
if [ [1] "log.txt" ]; then echo "It's a regular file" fi
The -f option checks if the file exists and is a regular file (not a directory).
Fix the error in the code to check if 'folder' is a directory.
if [ [1] "folder" ]; then echo "It's a directory" fi
The -d option checks if the path is a directory.
Fill both blanks to check if 'script.sh' exists and is executable.
if [ [1] "script.sh" ] && [ [2] "script.sh" ]; then echo "Script is ready to run" fi
-f checks if it is a regular file, and -x checks if it is executable.
Fill all three blanks to create a dictionary of files and their sizes if size is greater than 0.
declare -A file_sizes for file in *; do if [ [1] "$file" ] && [ $( [2] "$file" ) -gt 0 ]; then file_sizes[[3]]=$(stat -c%s "$file") fi done
-s checks if file size is greater than zero, stat -c%s gets file size, and $file is the key in the dictionary.
