Linux Shell script BASICS (6)

4) Functions If you write a bit more complexProgram, You will find that the sameCodeAnd you will also find it much easier if we use a function. A function looks like this: Functionname () { # Inside the body $1 is the first argument given to

Shell string processing

During shell programming, you often encounter the problem of getting the file name and file suffix. The general solution is as follows: 1 # Code 2 file = " thisfile.txt " 3 echo " filename :$ {file %. *} " 4 echo "

71. Special Features of command execution in crontab in shell,/bin/sh

1. When the crontab command is executedProgramIt is a little different and should be noted. For example, PS aux | grep File If the statement is executed directly in shell, the search scope is only the process currently executed in top, and the

Latency functions in Linux Shell

Latency functions in Linux Shell Latency processing is often required in Linux shell scripts. Therefore, sleep or usleep functions are often used. The difference between sleep and usleep is as follows: Sleep: the default unit is seconds.

Shell redirection and pipelines)

What is data stream redirection? What is data stream redirection? This should be explained by the running result of the command! Generally, if you want to run a command, it will usually be like this: Figure 5.1.1 data transmission

Linux Shell sends emails with attachments

If there is no body file, use echo to directly extract the body, for example: Echo "this is content" | mutt-s "this is subject"-A/path/Yourfile abc@local.domain-C bbb@local.domain If there is a body file, use CAT/path/contentfile | mutt-s "this

Use the current date and time as the file name in the Windows shell script

In Windows shell scripts, if you want to use the current date and timeCompositionFile name. You can use the following method: First obtain the string of the current date and time; Separate the desired characters; Finally, splice the file

Several tips in BASH Shell

1. for arithmetic operations. There are several assignment methods: Let a = 1 + 2Echo $ A = $(3 + 3 ))Echo $ A = $ [4*4]Echo "$" Set $ [A = 5*5]Echo "$" 2. Determine whether a directory exists:If [-d "$ (PWD)/.../candpointer"]; thenEcho "

Automatic SSH Login several methods Upgrade tutorial shell script Automation

Original article link   Before using sshpass, see Shell script Automation   Automatic SSH logon methods 1. Automatic ssh/SCP Method = A is a local host (that is, a machine used to control other hosts );B is the remote host (

Shell variable setting and display

[Root @ localhost ~] # Echo $ {mail}/Var/spool/mail/root[Root @ localhost ~] # Echo $ {mail ###/*/} # pre-Greedy match DeletionRoot[Root @ localhost ~] # Echo $ {mail #/*/} # pre-match DeletionSpool/mail/root[Root @ localhost ~] # Echo $ {mail %/*} #

Shell script redirection

In the Linux Shell environment, input and output redirection is supported, expressed by symbols . 0, 1, and 2 indicate the standard input, standard output, and standard error information output, which can be used to specify the standard input or

How to change the logon Shell

1. I want to know which shells have been installed on my machine? You can view the following two methods: First: [Rocrocket @ wupengchong ~] $ CHSH-l /Bin/sh /Bin/bash /Sbin/nologin /Bin/zsh Second: [Rocrocket @ wupengchong ~] $ CAT/etc/shells /Bin/

Getting started with shell programming (2)

Shell Structures are divided into three categories: sequential structure, branch structure, and cyclic structure. 1. If statement Syntax format: IfThenFi If the return value of the last command in statement sequence a is 0, execute the command

Base shell for file migration

Features required last time ~ The problem can be solved only by asking for advice on csdn ~ Hey hey ~  Code Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#! /Bin/sh Voicedir = "/var/www/html /"

[Reprint] Linux Shell shortcut keys

History display command history list ← (Ctrl + p) display the previous command Hide (Ctrl + n) display the next command ! Num: The num command in the History list. !! Run the previous command !? String? Execute the latest command containing string

Summary of code for automatically uploading and downloading ftp using Shell scripts in Linux

1. ftp automatically logs in to batch download files. Copy codeThe Code is as follows: ##### migrate/home/data from the ftp server to the local/home/databackup #### #! /Bin/bash Ftp-n Open 192.168.1.171 User guest

Code for reading and outputting data using shell commands

Shell scripts can read data in the following ways:1. keyboard input, default2. Read from the file3. Pipeline Command Transmission Echo functions:\ C: Do not wrap\ F: Paper Feed\ T: Skip\ N: line feed\ Indicates escape, for example: "\"/dev/rmt0 "\"

Shell programming Basics

1. Introduction to file typesLinux mainly includes the following seven file types: d directory-common file l symbol link s socket file B device file c character device file p name pipe File 2. Regular ExpressionRegular Expressions are very important

Shell script for monitoring disk usage (local + Remote)

Monitordisk. sh: Copy codeThe Code is as follows :#! /Bin/bash # Updated: PM By: leif (liangliwen@163.com) EMAIL =/usr/local/bin/email /Bin/df-h>/tmp/df.txt USE = 'df-H | grep-o [0-9] * % | grep-o '[0-9] \ +'' For I in $ USEDoIf ($ I> 95 ))Then$

First day of linux Shell Study Notes

The following are Shell Study Notes for 1-2 days: --------- I am a separator --------- Hardware is executed, and operations are performed between the kernel and hardware. Command parser. Shell script Components System commands Text processing

Total Pages: 541 1 .... 302 303 304 305 306 .... 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.