πάλι τίποτα...
εσένα δουλεύει έτσι;
Συντονιστής: konnn
if [ -s .crypt_list_open ]; then
cat .crypt_list_open
else
printf "Δεν περιέχει ονόματα"
fi
clepto έγραψε:εσένα δουλεύει έτσι;
if [ -s .crypt_list_open ]; then
cat .crypt_list_open
elif [ ! -s .crypt_list_open ]; then
printf "Δεν περιέχει ονόματα"
fi
έγραψε:
11. Bash File Testing
-b filename Block special file
-c filename Special character file
-d directoryname Check for directory existence
-e filename Check for file existence
-f filename Check for regular file existence not a directory
-G filename Check if file exists and is owned by effective group ID.
-g filename true if file exists and is set-group-id.
-k filename Sticky bit
-L filename Symbolic link
-O filename True if file exists and is owned by the effective user id.
-r filename Check if file is a readable
-S filename Check if file is socket
-s filename Check if file is nonzero size
-u filename Check if file set-ser-id bit is set
-w filename Check if file is writable
-x filename Check if file is executable
έγραψε:$ rm -f moo
$ touch moo
$ ls -l moo
-rw-r--r-- 1 sav sav 0 2011-08-28 23:55 moo
$ # Πρόσεξε τον αριθμό μηδέν στο αποτέλεσμα
$ [ -s moo ] && echo "File is non-zero, contains characters" || echo "File is empty"
File is empty
έγραψε:$ echo "" > moo
$ ls -l moo
-rw-r--r-- 1 sav sav 1 2011-08-28 23:55 moo
$ # Πρόσεξε τον αριθμό ένα στο αποτέλεσμα
$ [ -s moo ] && echo "File is non-zero, contains characters" || echo "File is empty"
File is non-zero, contains characters
pwd
ls -l .crypt_list_open
[ -s .crypt_list_open ] && echo "File is non-zero, contains characters" || echo "File is empty"
chris@chris-Aspire-5732Z:~$ pwd
/home/chris
chris@chris-Aspire-5732Z:~$ ls -l .crypt_list_open
-rw-r--r-- 1 chris chris 81 2011-08-29 01:06 .crypt_list_open
chris@chris-Aspire-5732Z:~$
if [ -s .crypt_list_open ]; then
echo "This file has data"
elif [ ! -s .crypt_list_open ]; then
echo "This file does not have data"
fi
rm .crypt_list_open
touch .crypt_list_open
ls -l .crypt_list_open
rm .crypt_list_open
touch .crypt_list_open
if [ -s .crypt_list_open ]; then
echo "This file has data"
elif [ ! -s .crypt_list_open ]; then
echo "This file does not have data"
fi
ls -l .crypt_list_open
echo "test" > .crypt_list_open
if [ -s .crypt_list_open ]; then
echo "This file has data"
elif [ ! -s .crypt_list_open ]; then
echo "This file does not have data"
fi
ls -l .crypt_list_open