Linux shell BASICS (6) and Linux shell Basics

Source: Internet
Author: User

Linux shell BASICS (6) and Linux shell Basics
6. Detailed description of Shell script programming links the content of the above five parts to increase understanding of Shell 01. shell script shell: ## perl # python # php # Different jsp scripts execute different texts, and the roles of execution are different. # shell scripts (the UNIX Like system has one principle: the shorter the program, the better) # bash csh tcsh ksh # which startx (view the file path)/usr/X11R6/bin/startx # vi 'which startx '#! /Bin/sh ...... # Vi/etc/rc. d/rc. sysinit (modifying system names, colors, and other attributes) # In echo $ SHELL/bin/bash scripts indicates annotations, but # In the first line has special meanings: for example: the first line of the character is not #, indicating that this is # In the first line of a bash script, but the second character is not I, indicating that this is the first line of a csh script. The character is #, and the second character is !, It indicates that the/usr/bin/python2.2 program specified after the call is called to execute the following script 02. In shell, the regular expression bash itself does not support regular expression, but only supports wildcards *? Regular Expressions can be executed through some commands, such as grep, vi, sed, awk, such as introduction 03 in Linux shell BASICS (II. interaction with shell scripts # cd/tmp/ddd/# ls ...... # Rm-rf * # vi #! /Bin/bashecho $1 \ $1 echo $2 \ $2 echo $3 \ $3 echo $ #\\ \# echo $? \ $ \? Echo $ \ $ wq # chmod a + x a #./a $1 $2 $30 $ # (How many parameters are input) 0 $? 3061 $ #./a aaa bbb cccaaa $ 1bbb $ 2ccc $34 $#0 $? 3064 $ # vi B #! /Bin/bashecho stop $1 $ 2ing ...... #./B httpd stophttp stoping ...... # Read data to the variable # echo output data # printf output data # vi #! /Bin/bashecho $1 (input) \ $1 echo $2 (input) \ $2 echo $3 (input) \ $3 echo $ # (check the parameters) \\ \# echo $? (If the shell command is successfully executed or not, execute other commands) \ $ \? Echo $ \ $ read-p "please input your name" 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 ......: Printf # printf "\ a" (generates a sound) 04. bash execution method 1. enter the absolute or relative path of the script/root/bachup. /bachup2.bash script or tcsh and script. Find the sub-shell to execute the bash or tcsh command to execute the script bash/root/backup3. Add ". indicates 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 the environment variable in the subdirectory) wq # cat bexport BBB #. /bpstree | grep-A2-B2 pstre # echo BBB #. /tmp/B (executed in the current shell script )#.. /B # echo $ BBB (obtain the BBB variable value) byf

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.