Shell scripting is the most basic knowledge of our OPS management, and here are a few examples of my learning process (compared to Daniel). The purpose of this blog is to record the course of learning scripts, but also to be able to discuss learning
Automated Format Partitioning method ---- non-interactive --- available for scriptingTo give the user a hint first, let him select a partition to formatFor i in ' mount|grep '/dev/sdb ' |awk ' {print '} 'Dofuser–km $i; Umount $iDoneDD If=/dev/zero
Using sh to write some small scripts will make the work easier, and some content may be unfamiliar to everyone (at least I am ),It is variable-related parameter expansion. Below are some simple descriptions and usage, which can make the code more
I. Condition statements
1,
If [expression]
Then
# Code block
Fi
2,
If [expression]
Then
# Code block
Else
# Code block
Fi
3,
If [expression]
Then
# Code block
Else if [expression] # Replace this field with Elif [expression]
Then
# Code block
Else
#
#! /Bin/bash
# Prompt user input
Echo-n "Please enter number"
Read N # Put the input value into Variable N
SD = 0
REV = ""
On = $ N # Save the value of Variable N to the variable on for later use
Echo "you put number is $ N"
While [$ n-GT 0]
Parse all commands in hadoop HDFS (the operation process is your own idea. You are welcome to correct them)
Interface Name
Function
Procedure
Get
Copy the file to the local file system. If multiple source files are
Echo-e "\ e [1; 31 m This is red text \ e [0 m"
\ E [1; 31 m set the color to red, \ e [0 m "will reset the color.
Each color has a corresponding color code, resetting 0, black 30, red 31, green 32, Blue 34, Magenta 35, cyan 36, white 37
To set
Hadoop supports command line operations on the HDFS file system, and supports shell-like commands to interact with HDFS file systems. For most programmers, shell-like command line operations are quite familiar, in fact, this is also one of the great
I. Regular Expression description
· Concept: Describe data with common attributes with a string of characters
· Note: when using regular expressions for matching, be sure to use the \ transfer symbol.
· Format:
A. grep [Option] 'regular expression'
It is easier to parse and modify XML using python, but if it is not convenient to use python, you can simply replace it with the SED command
For example, to replace the value of the port number in the following line:
21
You can use:
New_port =
The problem is as follows: perform a loop based on the number of Script Parameters $ #, and output each parameter $1 $2 $3 in sequence ...... I have a loop variable I $ I. When I get this variable I is 1, I want to use this 1 and then call $1, that
Some linnux commands have very powerful functions, mainly because they support many Command Options. For example, the [IP] command can be used to configure and manage IP addresses and route entries. This command can complete all the functions
#! /Bin/bash # program: # lzsh server log filter # History: #2014/07/01 Kom first release #2014/07/03 Kom remote and multi-Param support # Set pathpath =/bin:/sbin: /usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin :~ /Binexport path # Set Script
Note: you must first install an email server such as Postfix or Sendmail.
1. Apache
#!/bin/bash#apache.shnc -w2 localhost 80 if[ $? -ne 0 ]thenecho "apache is down,please check" | mail [email protected] -s "apache is
Answer 1:The shell is a typical UNIX program. It reads commands from the standard input and prints something on the standard output. This is simple and good.
The points is: In a graphical environment (like gnome or KDE) a program cannot just write
[[Email protected] ~] $ PS-Ef | grep initRoot 1 0 0 apr24? 00:08:25 init [3]
[[Email protected] ~] $ PS-Ef | head-N 1Uid pid ppid C stime tty time cmd
The second and third columns are the current process ID and parent process ID.
P1: process 0
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
This small program is simple, but it is the first shell script written by the novice. It has many factors to consider, but some errors are not handled ,,
#! /Bin/bash# Auth: dhh
Clear
Addr =/etc/yum. repos. d
Mkdir $ addr/bf>/dev/null 2> & 1
Mv $
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.