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
I've been studying this Linux shell program recently because I'm interested in this Linux system, so I've learned the shell programming at once.In fact, this Linux shell programming is a summary of the execution of this overall command, that is, if
Simple implementation of the more commands under Unix:#include #define Pagelen 24#define linelen 512int do_more (file * file); int see_more (file * file); int main (i NT Argc,char * argv[]) {FILE * fp;if (argc = = 1) do_more (stdin); Else{int
The command line can execute multiple commands at once, in the following ways:1. Separate each command;Note: The execution of each command will not affect the execution of other commands. In other words, each command executes,However, there is no
Programming Languages:Machine languageAssemblyAdvanced Language:Static language: Compiled languageStrongly typed (variable)Convert into executable format in advancesuch as: C, C + +, JAVA, C #Dynamic language: Interpreted language, on the flyWeak
Files that are often edited under Windows are sent to Linux remotely, ^m at the end of each line, which causes the shell script to run incorrectly, mainly because the editor under dos and the editor under Linux are inconsistent with the carriage
Comparison and judgment are the elements of program flow control. This article summarizes shell comparison and judgment statements for ease of searching and using. 1. Important comparison Operators Greater than:-GT Less than:-lt Greater than
Special characters
Purpose
Description
$ Variable
Get the value of a variable. If it is not initialized, It is null.
Returns the value of "variable". If it is not initialized, null is returned.
$
1 shell 的$! ,$?, $$,[email protected]
$n $1 the first parameter,$2 the second...
$# The number of command-line parameters.
$0 The name of current program.
$? Last command or function‘s return value.
$$
Shell script tracing and debug
Before scripts runs, the most feared problem is the syntax error! So how can we debug it? Is there a way to determine whether there is a problem without directly running the scripts? Haha! Of course! Let's take the
Recently, I started to get started with some shell commands because of compiling some files. It seems amazing and the usage is quite large. So I made some notes and the command sequence may be messy, the function is not fully functional.
1. Cut
Common shell script interpreters in Unix/Linux include bash, sh, CSH, and KSh. Bash is the most common interpreter in Linux.
Script Language isInterpreted languageWhen executing such programs, the interpreter (Interpreter) needs to read the source
There are a lot of for loop usage in shell. I always want to summarize it. Today I saw a summary of for loop usage on the Internet, which is very comprehensive. So I will turn to research and study...
1. For (I = 1; I 2. Commonly Used in shell is
1. The true and false values in bash are not the values 0 and 1 we generally think.
True and false are built-in shell commands that return logical values. For example:
$ True
$ Echo $?
0
$ False
$
Write a script to fully install the samba service and share the directory. Input by the user,The script is automatically determined based on user input. Then write to the samba configuration file and access Samba. The unified user is root.
The
Entry Level
Entry level: strings like 1, 2, 3, 4, and 5
#! /Bin/bashvar = "1, 2, 3, 4, 5" Var =$ {var //,/} For I in $ var; do echo $ I; done
In this way, the results can be output.Shap level
In the preceding example, the split string cannot
[Copyright statement: reprinted. Please retain the Source: blog.csdn.net/gentleliu. Mail: shallnew at 163 dot com]
The cut command is similar to awk. It extracts information from the line and is an awk of the feature weakening version.The format of
File descriptorBefore a process reads a file, it needs to open the file. When the process opens the file, Linux associates the file with a number (called a file descriptor ), the file descriptor is an index of the opened file in the input table.
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 |
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