Shell scripts randomly output 25 lines of a file

Preface I haven't written a shell script for a long time. Today I can see such a requirement in the group as follows: I also reviewed the shell script and wrote it easily. ProgramAfter testing, I basically passed the train of thought. First,

In Linux, write a monitoring log and mail shell.

Back_day = 'date-d' 1 day ago '+ % Y-% m-% d' Finance_linux_log_user =/home/admin/output/logs/user Target_server = "crmfinance1 crmfinance2 crm-finance03"Target_gov_auto_draft =$ {finance_linux_log_user}/govautodraft. log. $ {back_day}Target_gov_

Shell programming technology and example-Linux Kernel Analysis and Operating System Design

Although he does not know who Lu Jun is, his book is indeed easy to understand and has the meaning of training materials.. Linux Shell programming started from UNIX and was presented as a human-computer interaction tool in the early days. After

Some details about Unix shell programming

The test statement must have spaces before and after the equal sign, and there can be more than one space. To promote it, there must be no spaces before and after the equal sign of the value assignment statement, non-assignment statements require

Shell reads the row and column of a file

I want to perform frequent operations on a file. To obtain the values of different columns in each row, I know the method isWhile read lineDoEcho $ Line | awk '{print $1}' # obtain the value of the first column in each rowEcho $ Line | awk '{print $2

Shell script syntax

Shell script:#! /Bin/Bash must pass the first line #! To specify the Current Shell I. variables:"": Allows you to reference values of other variables using the $ symbol.'': Other variables cannot be referenced. $ is considered as a normal

Usage of Shell functions and source commands

The source command can load another script in one script. The following is an example: First, we define a function script named myfunc. Sh, as follows: #! /Bin/bashFunction Square{Local tempLet temp = $1*$1The sum of squares of Echo "$1 is: $ Temp"

Use tar in Linux Shell

We encountered the following problems during package packaging using Linux shell scripts: Tar: removing leading '/' from Member names Shell Content #! /Bin/sh Pkg_dir =$ {PWD}/release Pkg_name1_release.tar.gz Tar-zvcf $ {pkg_name }$ {pkg_dir}

How to obtain random numbers in Shell

From: http://standalone.javaeye.com/blog/511101   1. Use the shell variable $ randomEcho $ random 2. Use Random Functions of awkAwk 'in in {srand (); print rand ()}' 3. Use the System Device File/dev/random and/dev/urandomDd If =/dev/random | OD-

Changing the path in Shell

You often need to switch to a common directory, but the path is long and hard to remember. You want to use a script to enter the directory, but it will never change ....... Cause analysis: When the script is executed, only a sub-process is

Clistctrlex: A list control that supports file drag and drop and real-time monitoring-real-time shell monitoring using undisclosed API functions

I. RequirementsWhenever you create, delete, or rename a folder/file in the Explorer window, or insert and remove a mobile storage, Windows can always update all its views very quickly. Sometimes our program also needs this feature so that our

Variable reference in Shell (two methods: $ variable name, $ {variable name }).

I. Basics We define a variable (there cannot be spaces on both sides of the equal sign) Filepath =/var/home/SSSFilefilename = test001 When referencing this variable, we can directly use the variable name following $. For example, $ filepathYou can

Difference between $ @ and $ * in Shell

$ @ Refers to all command line parameters. Each parameter is enclosed "" $ * Indicates all command line parameters   The following procedure: Test1.sh ------------------- Sum = 0For VaRIn "$ @"DoLet sum = sum + $ VaRDoneEcho "sum = $

Usage of various quotation marks in Shell

Go to: http://goward.jimdo.com/2010/06/15/linux-shell%E5%90%84%E7%A7%8D%E5%BC%95%E5%8F%B7%E7%9A%84%E7%94%A8%E6%B3%95/ The difference between these characters is how they affect variables (such as $ name) and shell commands (such as date ). For any

Shell script memo

Common scripts in Linux include bash and shell. 1 #!/bin/bashecho "hello bash" #display one message Save the preceding content as a text file named me. The extension is arbitrary, but. Sh is often used as the extension. Run the command chmod A + x

Floating Point calculator in Linux Shell learning-Bash

Linux bash calculator is easy to use, at least it is easier to be lazy. How: 1. Use the command line# Scale indicates the exact number of digits of a floating point.[Root @ hostname ~] # BCBC 1.06Copyright 1991-1994,199 7, 1998,200 0 Free

Linux Shell: Test Command Parameter Parsing

Format: Test conditions Test-N string: string is not emptyTest-Z string: string is empty Test int1-EQ int2: int1 = int 2Test int1-ne int2: int1! = Int2Test int1-GT int2: int1> int2Test int1-ge int2: int1> = int2Test int1-lt int2: int1 Test int1-Le

Shell (7) User 2.16.doc

Command line parameters, Positional Parameter $0Complete program name(BasenameCommand to remove the path) $1The first parameter, exceeding9Hour$ {10} $ #Number of parameters $ *All parameters in the command line, as a word $ @All parameters in the

Shell Condition Statement

I. Shell Condition Statement (if usage) If statement structure [if/then/Elif/else/FI]   If condition test statement Then Action [Elif Condition Action Else Action ] Fi   If you are not clear about the conditional test statement, refer

Linux Shell study note 9

12.3 option analysis in shell script The first method is to use the case statement for manual processing. Method 2: Use the getopts command to analyze the options Syntax format: Getopts option-string variable Option-string is a string that contains

Total Pages: 541 1 .... 511 512 513 514 515 .... 541 Go to: GO

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.