Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Getting the Linux shell variable test     - What Java 8 fastest garbage collector (Programming)

- How to build Mono 3.4.0 / 3.4.1 on Windows (Linux)

- Remove old kernel on Ubuntu (Linux)

- Java reflection Introduction (Programming)

- Oracle 12C with multi-column index (Database)

- How to install Linux Kernel 4.0 On CentOS 7 system (Linux)

- Linux system installation Gitlab (Server)

- Four IDS intrusion detection tool under Linux environment (Linux)

- Linux redirection and piping (Linux)

- Not safe procedure under Linux (Linux)

- Android Studio commonly used shortcuts and how to follow the Eclipse Shortcuts (Linux)

- Error code: 2013 Lost connection to MySQL server during query (Database)

- blecat: Bluetooth Gadgets (Linux)

- SVN hook code set to synchronize Web directory (Server)

- Java to achieve local fileCopy (Programming)

- systemd-nspawn Quick Guide (Linux)

- Linux common network tools: batch scanning of nmap hosting service (Linux)

- Linux installation Jetty deployment under RedHat5 8 (Linux)

- Linux script to copy the folder to all folders with the same name (Linux)

- Use PuTTY key authentication mechanism for remote login Linux (Linux)

 
         
  Getting the Linux shell variable test
     
  Add Date : 2017-04-13      
         
         
         
  Format: test test conditions

String Test:

Note the space:
test str1 == str2 test strings are equal
test str1! = str2 test string are not equal
Are test str1 test string is not empty
If test -n str1 test string is not empty
test -z str1 test string is empty

Integer test
test int1 -eq int2 integer equality test
test int1 -ge int2 int1 test whether> = int2
test int1 -gt int2 int1 test whether> int2
test int1 -le int2 int1 test whether < = int2
test int1 -lt int2 int1 test whether < int2
test test int1 -ne int2 two numbers are not equal

File test
test -d file specifies the file is a directory
test -f file a given file is a regular file
If test -x file specified executable file
test -r file if the specified file readable
Are test -w file specified file writable
test -a file specified file exists
test -s file specify the file size is non-zero
Test statements generally not used alone, as a general statement if the test conditions, such as:

if test "hello" == "hello"; then
commands ....
fi

The above statement can also be simplified to (note that [] and spaces "between)
if [ "hello" == "hello"]; then
....
Look at a piece of code:

#! / Bin / bash
if test "hello" == "hello"; then
echo "equals"
else
echo "not equals"
fi
if test -z ""; then
echo "str is null"
fi
if test -n ""; then
echo "str is not null"
fi
if test "9"; then
echo "not null"
else
echo "null"
fi
#easy way
if [ "hello" == "hello"]; then
echo "equals"
else
echo "not equals"
fi
if [-f / root / test / test1]; then
echo "test1 is a file"
elif [-d / root / test / test1]; then
echo "test1 is a dir"
else
echo "i do not know the result"
fi
     
         
         
         
  More:      
 
- JQuery implements the same content merge cells (Programming)
- ORA-14400: inserted partition key does not map to any partition (Database)
- Some of the bibliographic management tools to good use on linux (Linux)
- Add local search to your Android app (Programming)
- Linux operating system security settings initial understanding (Linux)
- Ubuntu users to install the system indicator SysPeek 0.3 (Linux)
- Oracle table compression Technology Introduction (Database)
- rsync + inotify to achieve real-time synchronization (Server)
- How to use Quagga BGP (Border Gateway Protocol) router to filter BGP routing (Linux)
- grep command Series: grep command to search for multiple words (Linux)
- Ubuntu 14.10 Apache installation and configuration (Server)
- The Java way to stop a thread of execution (Programming)
- 32-bit and 64-bit integer in PHP and MySQL range (Database)
- Basic Tutorial: Linux novice should know 26 commands (Linux)
- The Linux disguised as windows to make the system more secure (Linux)
- openSUSE 13.1 / 13.2 installation SoundConverter 2.1.2 (Linux)
- Nginx server security configuration (Server)
- Ubuntu 12.04 / 14.04 users to install software LyX document processing (Linux)
- Linux system Iptables Firewall User Manual (Linux)
- MySQL database under Linux to achieve automatic backup scheduled backup day (Database)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.