recently, I have been engaged in Unix shell and read a lot of books and materials in this process, therefore, we will record some of the details to be noted for the purpose of memo and reminder. The shell here refers to the Bourne shell. I have
I have been using Linux recently and have accumulated some experience and skills. I will share it with you.
1. view the number of objects
WC-l filepath
2 File Sorting
Sort-K1-K2-T ""-n-r filepath
The command above is to sort the file
Method 1: send a simple email
Echo "Hello World" | mail-s "subject" yanggang_2050@163.com
Effect
Method 2: send an email in text format
#! /Bin/sh from_name = "from @ Yanggang" from = "yanggang@fruitsmobile.com" to = "yanggang_20
args.txt
#! /Bin/bash if [-Z $1] | [! -E $1] thenecho "Usage: cmd. sh input "exitfiecho $ 0for num in $ *; do echo" $ num "Done For I in $(SEQ-3 $ #); do echo $ I done for I in {0 .. 5} Do echo $ I done echo $ @ for (I = 4; I $ savepathawk '{A [$0]
Linux Shell is a command binder in Linux. It is easy to combine those tools to make a more powerful tool or automate the work at hand.
Batch is also available in windows, and this function is also available in theory. However, its syntax and
In the shell studyCode
# ! / Bin / Bash# User can keyin filename to touch 3 New Files.Path = / USR / Local / Sbin: / USR / Local / Bin: / USR / Sbin: / USR / Bin: / Sbin: / Bin: / USR / GamesExport pathEcho
Unix-like systems such as Linux always have a single file system tree, regardless
How many drives or storage devices are attached to the computer. Storage Devices
Are attached (mounted) at various points on the tree according to the system
Sunflower remote control software is junk!
A few days ago, I tried sunflower remote control software and felt it was drivingProgramInstallation is stupid. Later, the software was completely uninstalled from the control panel.
Next, the system's
#! /Bin/sh
# Show script description, different colors
Echo-e"\ E[34; 1 m ###################################### ##########\ E[0 m"
Echo-E"\ E[34; 1 m ### format like 'analysis _ log. Sh 2007-07-01 '###\ E[0 m"
Echo-E"\ E[34; 1 m ###
Linux Shell script basic learning Lecture 3: When we introduced shell commands and Process Control in the previous section, we could not talk about process control due to space limitations, today, we will only introduce the first three parts of if
Linux Shell script basics if you only look at the previous theoretical section, although there are some examples, but it is not systematic enough, here we will show you a specific example of Linux Shell script programming, to help you learn and
In the case of a lot of service logs or a lot of scattered files that need to be sorted together in batches, the shell script can be quickly used to solve the problem:
Date = $ (date + % Y _ % m _ % d-% H % m % s); find *-type F | while read file;
The script is:Nohup/mnt/nand3/h2000g>/dev/null 2> & 1 &For & 1, it should be file descriptor 1, while 1 generally represents stdout_fileno. In fact, this operation is a dup2 (2) Call. it outputs the standard output to all_result, and then copies the
I. Practice
In the current directory, You need to rename all the files in the format of school1, school2 ...... And so on
#! /Bin/bashEcho hello;
A =1;ForI in *;DoEcho$ I;MV$ I "School $";A = $ (($+1));#A = 'expr $ A + 1' doesn't seem to
It has been a while before the first post has been changing the series. At that time, I was just in touch with shell scripts and will be used temporarily at work. Learn the same thing, love the same, step by step.
1. Single and Double quotation
According to the shell programming of laruence's private dish, there is an inexplicable problem.For example:
# Test if else
Read-P "input y/n? : "YN
If [$ YN = "Y"]; then
Echo "continue ;"Elif [$ YN = "N"]; thenEcho "break ;"ElseEcho "PLS
First, you need to first understand how awk works: 1. Awk reads one row of the input file at a time. 2. For each row, it matches in the given sequence mode. If it matches, the corresponding action is executed. 3. If no pattern match exists, any
Document directory
Use the top script to retrieve the CPU of a process:
Add User:
IP address access statistics:
Calculate the sum of 2 numbers
Text Analysis
File Sorting
Print the swap partition size of the Local Machine
Output the time
Read files by row:Java code
While read myline
Do
Echo $ myline
Done
This program is to put the input file/Etc/passwdOne output.
If we only need to output username and home directory, We need to parse the file.Each row is roughly as follows,
Shell string truncation problem:1. Linux shell intercepts the first eight characters of the character variable by using the following methods:1. expr substr "$ a" 1 82. echo $ a | awk '{print substr (, 1, 8 )}'3. echo $ a | cut-c1-84. echo $5. expr $
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