Five, for security requirements each execution of the shell manually entered the password$ VI test5.sh#!/bin/bashEcho-n "Enter password for u_test:"Read PASSWDSqlplus-s/nolog Conn u_test/$PASSWDSELECT * from tab;ExitEof$ chmod +x
Shell Scripts (1)a Shell script is a special application that receives the operation commands entered by the user and interprets them, passes the actions that need to be performed to the kernel execution, and outputs the execution results. You can
1, mkdir newdir: New directory2. Touch filename: New file3. Vi/vim filename: Edit file4. grep [-ACIVN] [-A] [-b] [--color=auto] ' Search string | | Regular expression ' filename : A matching row was found from the file and displayed-A binary file
+++++++++++++++++++++++++ +++++shell Foundation +++++++++++++++++++++++++++++++1. Shell overviewShell definition:The Shell is a command-line interpreter that provides users with an interface system-level program that sends a request to the Linux
+++++++++++++++++++++++++ +++++shell Programming +++++++++++++++++++++++++++++++1. Basic Regular Expressionsregular expressions and wildcard characters:regular expressions are used to match conditional strings in a file, Regex contains matches, grep
The Linux/shell command is primarily intended to address:1, check whether a port is occupied;2, check which process is occupied by a port;3. See which ports a process occupies;For example, my Tomcat failed to start, the log display port is occupied,
Scripting is essential when you are doing Linux testing. Using Linux recently, I felt tired of hitting the keyboard too often, so I thought of the shell script. You can write too many commands into a script so that you can eliminate the time you
Determines whether the current user is the root administrator, and if so, executes the tar to perform a backup of the/etc/directory.#!/bin/bash# IF Current user was root then backup the/etcIf ["$ (id-u)"-eq 0];thenTar-czf/root/etc.tar.gz/etc
There is a ' batch ' file in DOS that writes multiple commands into a batch called. bat.In Linux, it can also be done, and more powerful, I write batch processing is in Ubuntu 12.04 LTSAll I have to do is move the pictures on the USB drive to the
The safest way to kill a processThe kill command is used without a modifier or a flag. First, use the PS-Ef command to determine the PID of the process to be killed, and then enter the following command: # Kill-PID Note: Standard kill
Traditional if statements -- use conditional expressions as if conditionsIf [conditional expression]ThenCommandCommandCommandElseCommandCommandFiConditional expressionsFile expressionIf [-F file] If the file existsIf [-d...] If the directory
In shell programming, some string variables are often processed. For example, commands such as awk, expr, sed, and TR are often used to calculate length, intercept substring, and replace character. Next we will introduce a simple string processing
Functions allow us to divide a complex function into several modules, so that the program structure is clearer and the code reuse rate is higher. Like other programming languages, shell also supports functions.
Shell functions must be defined before
1. Introduction to IFS
The shell script has an internal domain separator called ifs (internal field seprator. The complete definition is the shell uses the value stored in IFS, which is the space, tab, and newline characters by default, to delimit
In Linux, shell variables $ #, [email protected], $0, $1, $2 are interpreted as follows:Variable description:$Shell PID (processid)$!PID of the background process last run by Shell$?End code of the last command (return value)$-Flag overview set by
1. clearnginxlog. Sh
#! /Bin/bash
# Run at 2: 00 am every
Nginx_pid = "/run/nginx. PID"
Logs_path = "/opt/log/nginx"
Logs_date = "$ (date-d" yesterday "+" % Y % m % d ") _ 'date + % Y % m % d % H % m % S '"
MV $ {logs_path}/access. Log $
String truncation method in shell programming:
1. the GNU Linux Shell intercepts the first eight characters of the character variable by using the following methods:
1. expr substr "$ A" 1 8
2. Echo $ A | awk '{print substr (, 1, 8 )}'
3. Echo $ A |
After openvswitch 2.1.2 is installed, it is often possible to start and stop. To avoid repeating the script to start and stop the terminal code, it is best to write it in a different script to facilitate the next call. The premise is that
[Shell] judge the current user
Determines whether the current user is root. If the user is a root user, if not
#!/bin/bash#title: testus.sh#author: orangleliu#date: 2014-08-09#desc: get current user, if it is root user, tell us it is super user or
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.