Linux system sometimes needs to detect whether a certain condition is established, then you need to use the test command. There are many usages of test under Linux. Let's learn how to use the test command in Linux system with Xiaobian.
1. Determine the result of a command using test, which returns 0, or an integer. Return 0 for true, return an integer for error code
2. Get the result of the previous command using $?
3.
presence /home /www such a folder, so ls /home /www This command returns a result of 0. For example
My server above;
ie echo $? The return value is 0
My server above does not exist /home /kkk such a folder, so the return ls /home /kkk result of this command after command execution error code; < Br>
ie echo $? The result returned is 2. This 2 means that the file or folder does not exist.
4. Common file tester
-e indicates whether this file name exists
-f indicates whether this file name is a file
-d Indicates whether this file name is a folder
-r indicates whether this file name is readable
-w indicates whether this file is writable
-x indicates whether this file is readable execution
-S Indicates whether this file ask socket
4.1 on my server /home /www as a folder
so test -e /home The result of /www is 0, which is true. This file name exists
so the result of test -f /home/www is not 0, ie false, this file name is not a file
test -d /home /www result is 0, that is true, this file is named folder
4.2 on my server /home /kkk
the file name does not exist < Therefore, the result of test -e /home/kkk is not 0, that is, false, the file name does not exist
so the result of test -d /home/kkk is not 0, that is, false, this file name Do not ask for a folder.
The above is the introduction of the use of the Linux logic command test command. If you want to determine whether a condition is true, you will use this command. Have you learned it?
If the hardware clock and system clock in the Linux system are not synchronized, it may cause some e
When the name of the folder has a space, it can be easily deleted under Windows. Ho
DNS refers to the computer domain name system, which consists of a domain name reso
The rmdir and rm commands are deleted commands on Linux systems. The difference is
How to solve the corruption or loss of the grub.conf file on Linux system
Linux installation VMware Tools virtual machine graphic tutorial
What can I do if I can't access mysql under Linux?
How does the Linux system send mail?
Linux cancels the SSH login password
After CentOS installs vnc, prompts Could not start Xvnc?
Linux vsftp prompt 530 Permission denied how to do?
The difference between hardware processing and software processing in Linux system
Detailed method of configuring CentOS devices using Quagga software
Linux svn automatic update error report post-commit hook failed?
Expand Windows7 computer storage space Lightweight!
Network Troubleshooting for Home Routers
Win8 notebook touchpad can not be used how to solve?
Passing Win9 will abandon Metro style
What should I do if WinXP cannot install .Net?
Windows 8 enabled .NET framework 3.5 method
Linux Performance Tuning Basic Policy Settings
Windows xp/2000/2003 system automatic login setting method without entering password