Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Getting Started Linux Shell Scripting     - Use virt-manager to create and manage virtual machines (Linux)

- in no backup ex: error: Xin Tourou ah backup child process has Singles DAT / US person / bin / in no backup ex (Database)

- ARP Linux-related operations (Linux)

- Android judgment toward camera pictures (Programming)

- Linux, ls command to achieve (Linux)

- Linux System Getting Started Learning: The Linux anacron command (Linux)

- Java Virtual Machine Basics (Programming)

- RedHat virtual machine to install VMware Tools (Linux)

- Linux System Tutorial: How to browse the Linux command line, weather forecast (Linux)

- Linux security settings Notes (Linux)

- How to manage the time and date at systemd Linux systems (Linux)

- LogStash log analysis display system (Linux)

- JavaScript Advanced Programming notes event capture and event bubbling (Programming)

- Magical Virtualbox under Ubuntu (Linux)

- Unix average load average load calculation method (Server)

- Installation and configuration of Hadoop under Linux (Server)

- findmnt- Looking mounted file system (Linux)

- Oracle PL / SQL based cursor (Database)

- Linux System Getting Started Learning: the curl set custom HTTP header (Linux)

- Linux ps command (Linux)

 
         
  Getting Started Linux Shell Scripting
     
  Add Date : 2017-04-13      
         
         
         
  Recent study shell, record it.

if statement can be used:

1. The two parameters determine the size of

#! / Bin / sh
#a test about if statement
a = 10
b = 20
if [$ a -eq $ b]; then
echo "parameter a is equal to parameter b"
elif [$ a -le $ b]; then
echo "parameter a is less than parameter b"
elif [$ a -gt $ b]; then
echo "parameter a is greater than parameter b"
else
echo "i do not know the result!"
fi
Dynamic transmission parameters 2. The execution of the script


script

#! / Bin / sh
#a test about if statement
a = $ 1
b = $ 2
if [$ a -eq $ b]; then
echo "parameter a is equal to parameter b"
elif [$ a -le $ b]; then
echo "parameter a is less than parameter b"
elif [$ a -gt $ b]; then
echo "parameter a is greater than parameter b"
else
echo "i do not know the result!"
fi

$ 1, $ 2, $ 3 ... represent the received parameters
$ 0 for the name of the program
The total number of arguments passed to the program $ #
$? A code or shell in the shell program exits, if exits normally returns 0, otherwise non-zero value
* $ String consisting of all the parameters passed to the program
$ @ To "Parameter 1" "parameter 2" ... save all parameters form
$$ This program (process ID number) PID
$! PID of the last command

Use 3.for cycle

#! / Bin / bash
#a test about for and while statement
for i in {1..5}
do
 echo "hello world" $ i
done
Note: This sh does not support such an approach, use bash to run

sh support such an approach:

#! / Bin / sh
#a test about for and while statement
for i in 1 2 3 4 5
do
 echo "hello world" $ i
done
100 4. Create a folder in / root / test / test2 folder named test1 ~ test100

#! / Bin / bash
#create 100 folder in / root / test / test2
for i in {1..100}
do
`Mkdir. / Test2 / test $ i`
done

5. Preparation of the multiplication table, based on the input parameters to the output of a number of multiplication tables

#! / Bin / bash
for ((i = 1; i < = $ 1; i ++)) {
    for ((j = 1; j < = $ {i}; j ++)) {
       ((Ret = $ {i} * $ {j}))
       echo -ne $ {i} * $ {j} = $ ret "\ t"
    }
    echo
}
Note: The parameter -n a rear output does not wrap, e expressed support for the escape character
     
         
         
         
  More:      
 
- Seven Steps to Help Google Chrome Speed - (Linux)
- Lazarus for Raspbian installation (Linux)
- To install Internet security firewall Raiders (Linux)
- Nginx load balancing configuration (TCP proxy) (Server)
- Sudo and Root Account in Ubuntu related (Linux)
- Check with Hello World Docker installation (Server)
- Node.js developers must know four JavaScript concepts (Programming)
- Mac OS X system setup Google Go language development environment configuration tool Sublime Text 2 (Linux)
- C ++ pointer two third memory model (Programming)
- Oracle Database High-Risk Vulnerability Warning (Database)
- Java rewrite the hashcode method (Programming)
- To compile and install Redis Linux and master-slave replication configuration (Database)
- Big Data Common Glossary (Linux)
- Some safety precautions of Linux servers (Linux)
- HDFS Distributed File System Resource Manager Developer summary (Server)
- OpenSSL Introduction and compilation steps on Windows, Linux, Mac systems (Linux)
- MongoDB Study Notes (1) - Install MongoDB on Windows systems (Database)
- Start Linux ISO image directly from the hard disk (Linux)
- Java JDK has been able to compile without warning (Programming)
- Android Studio simple setup (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.