Example of Shell programming under Linux

1. Determine if a file is a block or character device file, and if it is copied to the/dev directoryRead-p "Input a file:" filenameIf [-B $filename-O-C $filename]ThenCP $filename/dev/Fi 2. Write a script to perform a simple subtraction operation

Shell Linux Basic Command instances

1. In the current directory, look for the files that were accessed within 20 minutes, and display the details of the file:Find./-name ' *.log '-mmin-20-exec ls-l {} \;Note: where {} is replaced by the file name, and the colon is used to indicate

Linux shell pushd popd dirs Command

1, dirs1) Functiondisplays all records in the current directory stack (the dirs command with no parameters displays the records in the current directory stack)2) Syntax(1) format: dirs [-CLPV] [+n] [-n](2) Options-C Delete all records in the

How Linux Shell executes

There are two ways that Linux shell executesShell scripts start with #!/bin/bash, and the shell is executed with the first row checked and executed internally in the following ways:$/bin/bash script.sh1. Execute with SH.$sh script.sh #脚本位于当前目录下Or$sh/

Linux-shell script command grep

[grep profile : ]grep is used to filter lines that contain specific charactersusage: grep ' pattern ' fileFor example: grep ' BBB ' aaa.txt--color # Search for the keyword BBB from the file Aaa.txt and highlight it.[Regular meta-character :

Linux Jobs (iii)-shell statistics The most frequently occurring n words in an article and sorts the number of output occurrences

Linux class Assignment Wednesday, if there is a poor consideration to the place, also please advise.Shell Processing Text See this blog for common commands related to##如果输入两个参数 is the first to count the number of words, the second is the article to

Shell script parsing 6 ---- case statement

The case structure in bash, which can be used for multiple branches.Case "$ Var" inCondition1);;Condition2);;*)Default statments ;;EsacFor example:#! /Bin/bashEcho "hit a key, then hit return"Read keypressCase "$ keypress" in[A-Z]) echo "uppercase

Shell script Practice Notes (6) -- Cluster Environment configuration Detection

  1). Background:During cluster deployment, consistent configuration and environment settings are required. for Virtual Machine clusters, you can copy, copy, and restore cluster machines by using images. different from physical machine clusters, if

Shell programming (ii) --- shell script description

Script: the source program implemented by the command flow control mechanism based on the actual situation. Script description: 1. Start with shebang, that is #! /Bin/bash. The path of the script interpreter is specified here. 2. Comments starting

Shell programming (4) --- condition judgment based on if

Single branch if statement If condition; then statement1 statement2fi Dual-branch if statement If judgment condition; then statement1 statement2 ...... Else statement3 statement4 ...... Fi Multi-branch if statement If condition 1; then statement1

An example of a netizen shell 20140702

After a netizen watched the old boy's shell video today, he asked the following question: 650) This. width = 650; "Title =" snap17.jpg "alt =" wkiol1oz8i_gwllfaaetvavr46c745.jpg "src ="

Introduction to Linux Shell scripts

8.1 count disk usage 1. Disk Space is a limited resource. 2 df and du are important commands used in Linux to measure disk usage. df is short for disk free and du is short for disk usage. 3. Find the disk space occupied by a file (or multiple files):

Shell implements simple process monitoring (watchdog)

#! /Bin/bashNAME = javaNOP =/bin/trueDATE = $ (/bin/date + "% Y-% m-% d % H: % M: % S ") ps-ef | awk-F "" '{print $8, $2}' | grep ^ java>/dev/null 2> & 1 case "$? "In0) # It is running in this case so we do nothing. echo "$ NAME is running OK. relax.

Production Environment backup shell script

Batch backup of multiple databases #! /Bin/bash BACKUP_HOST = "localhost" BACKUP_USER = "root" BACKUP_PASS = "123456" BACKUP_DIR = "/backup/mysql" BACKUP_DBNAME = "one two three" COPIES = 10 MYSQLDUMP = "mysqldump" TIMEPOINT = $ (date + % Y-% m-% d)

Shell Command Line shortcut

In the shell command terminal, Ctrl + n is equivalent to the downward direction key, and Ctrl + p is equivalent to the upward direction key. You can use them or the arrow keys in the Command terminal to quickly find historical commands. This is

Bash reference manual 5 (shell variable) continued 3

LINENO The row number of the script or shell function currently being executed. LINES The select command is used to determine the width of the selected columns. After receiving SIGWINCH, It is set automatically. MACHTYPE Is a string that

Loop Control of shell script Programming

Loop Control Structure of shell script Programming Loop Control-for Loop Syntax 1 For Variable in List Do Commands Done Syntax structure 2 For Variable in List; do Commands Done This List can be a List, variable, command, etc. A for Loop provides an

Prevent ssh timeout caused by long running of shell scripts

In some scenarios with high security requirements, the ssh timeout period is preset by the Administrator. After a period of time, the ssh connection is automatically disconnected. In this case, if you execute the script through ssh and the script

Text and log filtering in shell programming

1: grep command: Grep-v "char" file_name match text that does not contain "char" Grep-n-w "char" file_name completely matches a character Grep ^ s $ s is the text that matches the first or last row of s. 2: tr command Tr set1 set2 replace set

SHELL get the number of milliseconds

Conditions are required for exporting data from mongodb Currently, time is stored in milliseconds. Therefore, you must obtain the number of milliseconds from the shell. The first thing to say is the + % s parameter of the date command. I searched

Total Pages: 541 1 .... 500 501 502 503 504 .... 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.