Shell Programming for Linux Basics (3)-setting parameters for scripts

Types of variables for bash本地变量(局部变量)环境变量位置变量:$1,$2,$3, ...特殊变量:$?,$#,$*,[email protected]The location variable that gives the script the ability to get external parameters,$1 for the first argument,$2 for the second argument, and so onCases:vartest.

Shell---------Debug Mode

If you have been exposed to the C language, you should know that the C statement is executed when the error editor will indicate the specific error in that line, of course, these errors are the machine can not be executed error! Unfortunately our

Linux shell-shift Command Usage (reprint)

Position parameters can be usedShiftcommand to move left. Like whatShift 3said the original $4 now become $ $ , the original $ $ now becomes $ $, etc., the original $, $, $ discarded, don't move. The shift command with no parameters is

Shell determines disk space delete file

#!/bin/bash# @loyu################################################################################Sum= ' Df-h | awk ' {print $} ' | Sed-n 4p | awk-f% ' {print '} 'If [$sum-GT 75]ThenDate= ' Date +%y%m%d 'Echo-e "\NPDT"Echo

Hive streaming using shell scripts

One. HIVE StreamingIn hive, when you need to implement a function that is not possible with a function in hive, you can use streaming to implement it. The principle can be understood as: using language other than the HQL statement, such as Python,

Shell syntax-shell defining variables and calling variables

In the first line of the executable, we usually specify what interpreter to use to execute the file, such as the shell script, the beginning of the file is usually #! /bin/shRunning the shell will encounter three variables1. Local variables,

Shell to determine if a variable is empty

Determines whether a variable is empty.1. The variable is caused by "" quotation marksAs shown below:, you can get the result is NULL.#!/bin/shpara1=if [!-n "$para 1"]; Thenecho "is NULL"Elseecho "Not NULL"Fi2. Judging directly by variablesThe

How the shell generates a sequence 01 02 03 04 05

Seq Command IntroductionUse:Seq-print a sequence of numbersGrammar:seq [OPTION] ... Lastseq [OPTION] ... First Lastseq [OPTION] ... First INCREMENT LastCommon options-S,--separator=stringUse STRING to separate numbers (default: \

A legend is the shell test of Baidu interview

"Problem" script implementation, you can use Shell, Perl and so on. Save all the rows in file B, but none in file a, to file C and count the number of lines in C.To translate adult words is, suppose that there is a file a is:ABCDFile B is:1234ABNow

Shell Analysis Nginx Log Statistics

1. Count the IP addresses of the top 10 IP trafficCat Access.log | awk ' {print '} ' | Sort | uniq-c | Sort-nr | Head-n 102. View the current day IP traffic statisticsCat Access.log |grep "21/apr/2016" |awk ' {print $} ' |sort|uniq-c|sort-nr3. View

Some of the shell's points of attention (gradually replenished)

1) If you want to search the file name beginning with AB,#find/-name "ab*", pay attention to double quotation marks, or you will get an error.If you search a file, AB starts the sentence,#grep "^ab" file name , if using cat, is to show the full text.

Shell Foundation II

1.shell ScriptNew text, suffix sh, for example: abc.shAttention:The first line in the script needs to write #! /bin/bash#! Specify how to use the interpreter to execute the source code# indicates a commentAttention:PHP can also write shell

Shell Practice Verification Number

Original: https://leetcode.com/problems/valid-phone-numbers/Given A text file file.txt that contains list of phones numbers (one per line), write a one Liner bash script to print All valid phone numbers. Assume that a valid phone number must

Shell script execution Log Generic module

TargetImplementation records the start time and end time of the shell execution. Execution state, error message, and so on, the script calls the function in the way that the function encapsulates the log recordSource CodeGeneral function Script

Shell Scripting related

Issue 1: Read the same line of two files simultaneously and insert the rows of two files into the same text# cat aaa1a2a3a4# Cat bbb1b2b3/# vim aa.sh#!/bin/bashwhile read-u3 i && read-u4 j;doecho $i $jdone >cc 3Note that READ-U3 I reads the contents

Shell Script--Guess number

#!/bin/bash#It ' s written by Caibingsen#Date: 2016-03-15# # Function: Guess the number in the 0-9 range# # Requirements: 1, automatically generate a number each time# # 2, guess wrong five times auto exit# 3, guess the automatic exit# # 4, input

Shell implementation Trim Function-removes spaces on both sides of the string (including the Tab,space key)

The shell implements the trim function effect to remove spaces on both sides of the string, and the following three commands are equivalent, all of which can be implementedSed ' s/^\s*//' totrim.txt |sed ' s/\s*$//' >trimed.txtSed ' s/^\s*//;s/\s*$//

Restart Tomcat's shell script under the Linux system

Restart the Tomcat shell script under the Linux system: tomcat_home=/opt/apache-tomcat-6.0 . 32 #找到tomcat进程的id并kill掉 ps -ef | grep Tomcat | awk { print $ "} | sed -e s/^/kill-9/g | sh - #删除日志文件, if you don't first delete it, you can leave

Java calls the shell to get the return value

Transferred from: http://blog.csdn.net/tengdazhang770960436/article/details/120148391.shell file return.shEcho 1Echo 2Echo 32.java file Test.java[Java]View PlainCopy Import Java.io.BufferedInputStream; Import Java.io.BufferedReader; Import

Sorting algorithm--shell sorting

PrincipleDivides the sorted array into sub-sequences (this depends on the originally set step value), then inserts the sequence directly between the individual sub-sequences, and then the increment (that is, the step value) and then inserts the sort,

Total Pages: 541 1 .... 533 534 535 536 537 .... 541 Go to: GO

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.