Linux Shell Basics (vi)

Source: Internet
Author: User

Six, shell script programming details of the above five parts of the content, in series to increase the understanding of the Shell 01.shell script shell:# #perl #python#php#jsp different scripts to execute different text, the role of execution is not the same; #shell Scripts (UNIX like system has one principle: the shorter the program, the better) #bash csh tcsh Ksh#which startx (View the path to the file)/usr/x11r6/bin/startx#vi ' which startx ' #!/ Bin/sh. #vi/etc/rc.d/rc.sysinit (Modify the system name, color, and so on) #echo $SHELL the # notation in the/bin/bash script, but the # in the first line has a special meaning: such as: The first line of the word printable #, Indicates that this is a bash script in the first line is #, but the second character is not I, which indicates that this is a CSH script the first line character is #, and the second character is! That represents a call to the/usr/bin/python2.2 program specified later to execute the following script 02.shell the normal expression bash itself does not provide regular representation support, only the wildcard character *? Regular expressions can be executed with some commands, such as the introduction of Grep,vi,sed,awk in Linux shell (ii) 03. Interaction with Shell scripts #cd/tmp/ddd/#ls ... #rm-rf * #vi a#!/bin/ Bashecho $ \$1echo $ \$2echo $ \$3echo $# \$\ #echo $? \$\?echo $$ \$\ $wq #chmod a+x a#./a$1$2$30 $# (input number of parameters) 0 $?3061 $$#./a aaa bbb cccaaa $1bbb $2CCC $34 $ #0 $?3064 $$ #vi b#!/b In/bashecho Stop $ $2ing ... #./b httpd stophttp stoping ... #read读入数据给变量 #echo output data #printf output data #vi a#!/bin/bashecho (do input) \$ 1echo $ (do input) \$2echo $ (do input) \$3echo $# (see several parameters) \$\ #echo $? (if the shell command is executed successfully, do not succeed, perform other) \$\?echo $$ \$\ $read-P "please Put yourName "Aaaprinf" $AAA is Fool "#./a AAA bbb cccaaa $1bbb $2CCC $34 $ #0 $?3064 $ $please Input your NAME:BYFBYF is fool#printf "\ t hello\n"Hello#help Printf#man bash ...:p rintf#printf "\a" (produces a sound) 04.bash execution mode 1. Enter the absolute path or relative path of the script/root/bachup./ Bachup2.bash scripts or tcsh and scripts, find the child shell to execute the script bash/root/backup3 with bash or tcsh. Add "." to the path of the script to indicate that there is a script under a path: /backup. /root/backup#vi bpstree |grep-a2-b2 pstreebash--pstree#pstree |grep-a2-b2 pstree#bash./bbash--bash--pstree#chmod a+x Bbash--bash--pstree#vi bexport Bbb=byf (set BBB to the BYF directory and sub-directory environment variable) wq#cat bexport bbb#./bpstree |grep-a2-b2 pstre#echo BBB #. /tmp/b (executed in the current shell script) #. ./b#echo $BBB (take out the variable value of BBB) BYF

Linux Shell Basics (vi)

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.