/*************************************** ******************************* Author: Samson* Date: 08/18/2012* Test Platform:* GNU Linux version 2.6.29.4* GNU bash, version 4.0.16 (1)-release (i386-redhat-linux-gnu)
************************************
Formatting: printf'print format' actual contentWhat are the characters represented by the value 45?Printf'/x45/N' Note:/xnn is a two-digit number, which can be converted into characters.
Introduction to SED and awk tools:You can analyze the
1. Date
Get time and date
Date = 'date + % Y-% m-% d-% H'
Echo $ {date}
2. cron
Add a Task Scheduler
# Vi/etc/crontab
Crontab task format
* *** User task
Minute hour, day, month, week, user task
Field
Description
To delete logs, you need to switch the user to specify the directory for deletion. Therefore, you need to determine whether the script can be automatically implemented. The direct su command fails, so telnet to the local machine is used.
Difference between $ * and $ @ in Shell
A little bit about $ * and $ @ is also learned by cainiao.
$ *All location parameters are used as a word.Note: "$ *" must be referenced.$ @It is synonymous with $ *, but each parameter is an independent ""
Common grep command syntax 1. Double quotation marks and single quotation marksWhen you input a string parameter in the g r e p command, it is best to enclose it with double quotation marks. For example, "m y s t r I n g ". There are two reasons for
Use source, dot (.) when the shell script is executed, no sub-processes are generated. The shell script runs in the current shell, variables declared in shell scripts are visible in the current shell.
When the shell script is directly executed using
Recently, I learned the content of shell script writing and read the script easily. But in fact, there are still some difficulties in hand, so I decided to find some examples to practice, after all, there is a saying that is very good: "I have to
-B. returns true if the file exists and is a block file.-C: returns true if the file exists and is a character file.-D. If pathname exists and is a directory, true is returned.-E: returns true if the file or directory specified by pathname exists.-F
1 #! /Bin/bash 2 3 # variable assignment and replacement 4 5 A = 375 6 Hello = $ A 7 8 # --------------------------------------------------------------------- 9 # note that when assigning values, do not have spaces before and after the equal sign. 10
Linux scripts are huge and powerful.
Definition:
Function Name () // function can be omitted
{
Command
}
Call: directly use the function name in the script. Of course, you can also include parameters such
Function Name parameters (separated by
[Reserved] common usage of typeset
Http://www.chinaunix.net Author: lonely fire published in: 09:50:34
[Comment] [View Original] [Shell discussion area] [close]
Typeset can be
Create an unzipped installation package in Shell
Principles
In Linux, you can use several basic commands to create a self-extracting program. The principle is: The Cat command can be used to connect two files (with> append can achieve the same
The most important script language in Linux is Bash. I will write this (I will only use this :)). Compared with other development languages (such as C), bash is a relatively simple language, mainly used to write some script code, some batch
1,Find Command OptionsThe f I n d command has many options or expressions. Each option follows a horizontal bar -.-Name: searches for files by file name.-Perm searches for files based on the file permissions.-Prune can use this option to make the f
1. Run the &: & command on the left (command 1) To return the true result (0 is returned, and the result is successfully executed), and run the & command on the right (command 2) can be executed;
2. Run |: if | the command on the left (command 1)
Implement a shell script for folder SynchronizationAlgorithm:
1. First find/pathname-print> filea # Get the full names of all files in the two folders. 2. Compare files. Delete unnecessary files in the folder to be synchronized. Then obtain the
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.