Shell script Implementation empties log

Source: Internet
Author: User

#!bin/bash

Log_dir=/var/log

Root_uid=0

if[' $UID '-ne ' $ROOT _uid ']

Then

Echo ' must is root to run this srcripts '

Exit 1

Fi

CD $Log_dir | | {

echo "Cannot change Necessarydirectroy" >&2

Exit 1

}

Cat/dev/null >messages&&

Echo ' log is cleaned up. '

Exit 0 #返回0 Indicates success, 1 indicates failure

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M02/9C/62/wKioL1lvypHAiZmxAAEGHHfBKsk549.png-wh_500x0-wm_ 3-wmp_4-s_2820742897.png "title=" 655.png "alt=" Wkiol1lvyphaizmxaaeghhfbksk549.png-wh_50 "/>

Types of shells

650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/9C/62/wKioL1lv1lDwddflAADxcly1ozU203.png-wh_500x0-wm_ 3-wmp_4-s_1394413097.png "title=" 1122121.png "alt=" Wkiol1lv1ldwddflaadxcly1ozu203.png-wh_50 "/>

Default shell for common Linux systems

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M02/9C/62/wKiom1lv14Cw3iv0AAFFcST_DJI591.png-wh_500x0-wm_ 3-wmp_4-s_1681327574.png "title=" 22222.png "alt=" Wkiom1lv14cw3iv0aaffcst_dji591.png-wh_50 "/>


View Shell;echo$shell;bash used by Linux--Vsion

Shell Execution Method:

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M02/9C/62/wKiom1lv2PnT5vMCAAIWiNsqvzI706.png-wh_500x0-wm_ 3-wmp_4-s_133048985.png "title=" 1111111111111111.png "alt=" Wkiom1lv2pnt5vmcaaiwinsqvzi706.png-wh_50 "/>

Shell Environment variables:

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M00/9C/62/wKiom1lv3DWya3EnAAricAnQwJY523.png-wh_500x0-wm_ 3-wmp_4-s_170482539.png "title=" 4444.png "alt=" Wkiom1lv3dwya3enaaricanqwjy523.png-wh_50 "/>

Export lang=en

Set Environment variables (global), environment variables must be uppercase ;

"The single quotation mark is what you see is what you receive;

" '" double quotation marks: The variables and commands in the quotation marks will be parsed out, it is recommended to use

No quotation marks: consecutive can not double shadow number

Awk has nothing to do with the good shell of the upper;

NFS is the abbreviation of the network file system;

Create 10 of files in bulk with the shell

#! /bin/bash

Dir =/test

[!-D $ dit]&&mkdir-p $dir

For file in ' Seq10 '

Do touch/test/test-$file. html

Done

Cond..


Shell script Implementation empties log

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.