UbuntuLinuxBashShell script learning notes

Source: Internet
Author: User
I am a beginner in Linux and have just started learning. I will record my learning growth and share it with you! My system is Ubuntu8.04, And the Script Editor uses VIM! The Shell language uses BashShell. Basically all Shell languages are connected! First, make preparations! If you do not have the VIM text editor in your system, enter the following command in the terminal: sudoapt-getinstallvim and install it as prompted.

I am a beginner in Linux and have just started learning. I will record my learning growth and share it with you!

My system is Ubuntu 8.04, And the Script Editor uses VIM! The Shell language uses Bash Shell. Basically all Shell languages are connected!

First, make preparations! If you do not have the VIM text editor in your system, enter the following command in the terminal: sudo apt-get install vim and install VIM as prompted! The system has the text editor, and the following is a poor language. Next, let's start learning the Bash Shell language!

PS: in fact, as long as it is a text editor, you can write scripts, but I use VIM to write, so that's it.

Start the first Shell script.

Enter the following command in the terminal:

Vim test.txt (note that there is a space in the middle)

Press enter to enter the VIM environment. At this time, you cannot write data, because you have not typed "I". This is a usage specified by VIM, I had to do what I said. When you press "I", you will find that "-- insert --" is displayed in the lower left corner of the editor. In this situation, you can write programs. Write the following content:

#! Bin/bash

Clear

Echo ""

Echo "Welcome to the world of Ubuntu Linux! "

Note the space between echo and the following content. After the preceding content is entered, perform the following operations:

Press "Esc" (double quotation marks are not input content and are only highlighted)

Enter: ": wq" and press Enter. Then you return to the terminal status. (Double quotation marks are only highlighted because they are not input content)

At this time, your program has been compiled, and you need to grant permissions to the test.txt file. Perform the following operations:

Enter chmod 711 test.txt at the terminal prompt and press Enter.

Next, run your program and perform the following operations:

Enter./test.txt at the end of the terminal prompt.

It appears. This is the first time that every language you learn appears in front of your eyes. This is the one that keeps you pleasantly surprised:

Welcome to the world of Ubuntu Linux!

Well, the above content is our first Bash Shell script. The following describes the specific meanings of each part.

Vim test.txt

This is a command in the VIM editor. The syntax is: vim file name. suffix. It means that we use the VIM editor to compile a file. I use vimto compile a file named test.txt.

#! Bin/bash to start Bash

Clear the screen before running the program

Echo "" echo is the output command, which is a blank line in the output

Echo "Welcome to the world of Ubuntu Linux! "This is to output" welcome to the Ubuntu Linux World "on the screen.

Press "Esc" to tell VIM that we want to exit writing, and ": wq" to tell VIM that we want to exit the editor and save the written content.

"Chmod 711 test.txt" is the permission granted to test.txt that can be read, written, and executed by any user with any permissions.

The above is the first lesson to learn Bash Shell!

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.