Linux Shell Programming Grooming

Source: Internet
Author: User
Tags echo command

Often read some of the books about Linux still feel unable to fully grasp this knowledge can not be fully mastered as long as you can achieve proficiency in the use of after all, do research and development is able to quickly make products to sell private enterprises as the king of the era.

These days make the product feel a little bit less skilled in the shell part of the foundation here to summarize some points in order to have a new understanding of the shell also make some notes and share with you.

the foundation of a shell

The shell is a program written in C that is a bridge for users to use Linux . The shell is both a command language and a programming language.

A Shell is an application that provides an interface through which users access the operating system kernel's services.

Basic work with Shell programming

1 Open an editor to save in. sh format.

2 permission settings chmod 777 *.sh or chmod +x *.sh

two first script and script structure

A good script should be written in such a structure

#!/bin/bash# author Sun Guodong # Description of the first script classic Hello World!echo "Hello world!"

Let a person see at a glance

The main basic content of the three scripts

Shell variable Shell pass parameter shell array shell operator Shell echo command Hell printf command shell Test command shell Process Control Shell function shell input/output REDIRECT Shell file contains

Above this main basic content basic Learn these can write simple script

41 examples to summarize learning shell usage

#!/bin/bash# Sun Guodong # Description: instance, description shell basic definition #!/bin/bash# output Hello world!echo "Hello World" #变量定义, can't use spaces, who defined, to do! name=sgd# Delete variable #unset name# variable reference, preceded by a USA symbol Echo $name # Gets the length of the string Echo ${#name} #取字符串, from No. 0, back to two characters out Echo ${name:0:2}#  Find the location of the string string= "Alibaba is a great company" Echo ' Expr index "$string" is "#数组定义array = (1 2 3 4) #引用数组的元素echo ${array[0]}echo ${ARRAY[1]} #引用所有数组的元素echo ${array[@]} #数组的长度echo ${#array [@]}


This article is from the "Sun Guodong" blog, make sure to keep this source http://qtlinux.blog.51cto.com/3052744/1750089

Linux Shell Programming Grooming

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.