Date Created: 2016/02/29Update on: 2016/02/29
Shell variables cannot be left blank on both sides of the equals sign, otherwise the shell will mistake the variable name for the command name
Variables enclosed in double quotes can be replaced
This script is what you might need to do after you've just installed CENTOS6.6. When learning CentOS, you can run this script to do some configuration to help you not be bothered by these firewall yum SELinux IP.#!/bin/bash #判断是不是root用户if [[ "$
1. List the directory under the current directory (only one level is required)1 #!/bin/bash 2 for f in ' LS ' 3 do 4 if [-D $f] 5 then 6 echo $f 7 fi 8 done2, the current directory of files (only need a level) listed1 #!/bin/bash 2 for f in ' LS ' 3
Nonsense not much to say, directly on the code, the basic implementation of subtraction functions:#!/bin/bash# author by alsww# date : 2016.02.03# mail : [email protected]# blog : alsww.blog.51cto.comprint_info () { printf " Please enter the
Shell's Features~/.bash_history command history to store files, log out after saving.$HISTSIZE the number of command history bars, which allows the ~/.bash_history file to store the number of command bars, by default.!! : Previous command!$: Last
Bash variable Category:
Local variable: Also called local variable, valid only for the current shell process
Environment variables: current shell and its child shell, child shell ....
Special variables: $? The status of the last
Catalogue
1. List of special variables
2. Special Instructions
In the shell, variable names can only contain numbers, letters, and underscores, because some variables that contain other characters have special meanings, and such
1. Clear the contents of the fileCat/dev/null >>/var/log/messages2. The script to determine whether the user is the root userRoot_uid = 0 # $UID is 0 o'clock, the user has root user rightsIf ["$UID"-ne "$ROOT _uid"]Thenecho "This user isn't
Output System Information#!/bin/bashif [$#-eq 0];then echo "---------------------------------------------------------------------------" # OS type echo "OS Type: $ (uname-o)" # OS Release Version and Name echo " OS Release Version and Name: $
1. Describe the results of the following commandsMore/etc/shellsDisplays all the contents of the shells text.Echo $SHELLView the shell program used by the current user.History-cClear historical and practical commands.Echo $HISTIZERecord the history
ObjectivePractice the shell to improve your logical abilities.ScriptTriangles and diamonds are implemented through several for loops, but can also be used while.Here is the script content:Triangle#!/bin/bashread -p "Please input the longs:"
The use of SEQ in the shellExample:/bugzilla/group.00....group.99 more than 3 years of data mv to/history/bugzilla/group.00...group.99Seq-w (-w = 0 in front to make the same width)#!/bin/bashFor Inum in ' seq-w 00 99 'DoSsdir=/bugzilla/group.
Today is WebSocket,Complete the getops of a shell first, Monday will be useful.#!/bin/BashEcho "usage:./$0-T (prism|opscripts)"functionscp_prism () {Echo "scp_prism ()"}functionscp_opscripts () {Echo "scp_opscripts ()"} whilegetopts t:h OPT Do
Write a script: The requirements are as follows:1: Say hello to each user in the/etc/passwd directory, and indicate its UID number! (Eg:hello Root,your uid is 0)2: How many accounts does this script share?#!/bin/bashName= ' cat/etc/passwd |awk-f: ' {
The Linux shell is much more powerful in programming than Windows batch processing, both in loops and operations. Data types are not comparable. Here's a summary of some of the things that an individual does when it comes to working with arrays.1.
Linux Machine First installs wmi-1.3.14.tar.bz2TAR-JXVF wmi-1.3.14.tar.bz2CD wmi-1.3.14MakeCP samba/source/bin/wmic/usr/local/bin/Pass parameter information through the file into the script and get the outputWmi.sh ————————————————————#cat/mess/host|
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.