3.0-vim editor and bash condition test

Source: Internet
Author: User
Tags readable

Multi-file Mode:

Vim FILE1 FILE2 FILE3 ...

: Next Next

:p Rev A previous

: First One

: Last One

: Wall Save All

: Qall Quit all


Window-delimited mode:

Vim-o|-o FILE1 FILE2 ...

-O: Horizontal split

-O: Vertical split

Switch between windows: Ctrl+w then arrow (arrow: Flag on keyboard)


Single File Window segmentation:

Ctrl+w,s:split Horizontal Split

Ctrl+w,v:vertical Vertical Segmentation


Customizing the working characteristics of vim:

Configuration file: Permanently valid

Global:/ETC/VIMRC

Personal: ~/.VIMRC

Last line: The current VIM process is valid

(1) Line number

Display: Set number, abbreviated as: Set Nu

Cancel display: Set Nonumber, abbreviated as: Set Nonu

(2) Bracket matching (automatic matching of left and right brackets in programming)

Match: Set Showmatch, abbreviated as: Set SM

Cancel match: Set Noshowmatch, abbreviated as: Set NOSM

(3) Auto Indent

Enable: Set AI

Disabled: Set Noai

(4) Highlight Search

Enabled: Set Hlsearch

Disabled: Set Nohlsearch

(5) syntax highlighting

Enabled: Syntax on

Disabled: Syntax off

(6) Ignore character case

Enable: Set IC

Disabled: Set Noic

Get help

: Help

: Help Subject

Problem: How to Set tab indent to 4 characters


Practice:

1. Copy the/etc/rc.d/init.d/functions file to the/tmp directory: Replace the/etc/sysconfig/init in the/tmp/functions file with the/var/log

2. Delete the # number at the beginning of all lines in the/tmp/functions file that begin with # and have at least one white space character after #

#hello

# Hello (Remove the # character with a space after this #)


Bash condition test:

Test method:

Test EXPRESSION

[EXPRESSION]

[[EXPRESSION]]

To test the category of an expression:

Numerical comparison

String test

File test


File test

Existence test:

-A FILE (same-E, rarely used)

-e File: Document existence test, existence is true, there is no false

Presence and category testing:

-B File: Exists and is a block device file

-C file: exists and is a character device file

-D file: Exists and is a catalog file

-F file: exists and is a normal file

-H file or-L file: exists and is a symbolic link file

-P file: exists and is a named pipe file

-S file: exists and is a socket file

File permission test:

-R FILE: exists and is readable

-W FILE: exists and is writable

-X FILE: exists and is executable

File Special Permissions Test:

-G FILE: Exists and has Sgid permissions

-U FILE: Exists and has suid permissions

-K FILE: Exists and has sticky permissions

File size test:

-S FILE: exists and is not empty

Whether the file is open:

-T FD:FD indicates whether the file descriptor is open and related to a terminal


-N File: Files are automatically modified after they have been read for the last time

-O File: Whether the current active user is a file owner

-G file: whether the current active user is a group of files

Binocular test:

File1-ef whether File2:file1 and FILE2 point to the same inode on the same device

File1-nt File2:file1 is new to FILE2

File1-ot File2:file1 is older than FILE2

Combination Test conditions:

Logical operation:

The first way:

COMMAND1 && COMMAND2

COMMAND1 | | COMMAND2

! COMMAND

For example: [-E file] && [-R File] files exist and are readable

Note: When doing a file test, be sure to pay attention to whether it is root or ordinary user, if it is root permission to judge there will be problems


The second way:

Expression1-a EXPRESSION2

Expression1-o EXPRESSION2

EXPRESSION

You must use the test command to

# [-Z $hostName-o $hostName = = Bogon] && hostName test

# [-f/bin/cat-a-x/bin/cat] && cat/etc/fstab


3.0-vim editor and bash condition test

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.