Linux shell scripts and vim common operating notes

Source: Internet
Author: User

This note records the most basic vim and shell operations.

What can shellscript do?

Shellscript similar to Windows batch processing, you can put a lot of instructions together, so it is easy to execute multiple commands through an operation. Very light weight, efficient.

Write in Vim

Vim/vi Editor is very powerful, very many functions, shortcut keys, instructions more, just need to know the most commonly used is enough.

VI has 3 modes of operation

1. Command mode

The default mode after entering is the command mode. The command can be accepted but not shown in clear text.

2. Input mode

Command mode press the a key to enter input mode (also press I, O, S, etc.). Press ESC to return to command mode.

3. Colon mode

Enter a blur in command mode to enter the command line.

VI exit

1. Command mode

: q! Quit without saving

: Wq Save and then exit

2. Command mode

ZZ/ZQ Save/Do not save exit

VI Configuration

Synon Syntax highlighting

SETNU Display Line numbers

VI Edit (command line mode)

YY copy entire row

P paste

x Delete cursor characters

DD Delete cursor entire line

U undo

. Repeat

Write a shell script

The shell has a lot of script interpreters here, with bash

#!/bin/bash#asimple shell Script Example#afunctionfuncitonsayhello ()                function {echo "Enter Your Name:" Readname          Read the variable from keyboard input echo "Hello $name"}echo "programme starts here ..."  main process Sayhelloecho "programme ends."

Hit ZZ to save the exit.

Shell execution

1.sh command execution

shhello.sh

2. Add execute permissions to the script, and then use the./Command to execute

chmod755 hello.sh

./hello.sh

Add 2 most common Linux commands by the way

CD Replacement directory: CD [DirName]

1.cd/usr/bin/

2.cd~ Back Home

chmod changing properties

where r=4;w=2;x=1

chmod*** represents User/group/other permissions respectively

Chmod777 is all right.


Welcome to participate in the discussion and follow This blog Weibo personal home Subsequent content continues to update Oh ~

reproduced please respect the author's labor, complete reservations The above text as well article links , thank you for your support!



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.