Shell BASICS (10) including shell scripts and shell Basics
Preface
Write it here; the basics of shell are almost finished. I hope you have a basic understanding of shell. You may be eager to try it out and want to write some program exercises. This will be very good for you. We suggest you go to chinaunix to study. I am li0924. I will do the exercises on a regular basis. Is a good learning platform. Maybe the most frequently encountered question above is awk & sed. Of course, there are some clever use of commands.
Body
In this article, Shell can also contain external scripts to merge the content of the external scripts into the current script.
Use source or.
For example:
. Filename or source filename
The test cases are as follows:
Lottu03.sh $ cat lottu03.sh #! /Bin/bashvar01 = "20" echo $ {var01}. lottu01.shsource lottu02.sh execution result: $./lottu03.sh 20 hello world! Please input your name? LHI, l
[Thinking] Now we can see that the script contains ../file. sh, which knows what the two vertices represent.
Postscript
The basics are completed. The skills will be sorted out later.
Shell script searches for files whose names do not contain abc
My sentence is simpler:
Find is a dedicated search command. The following describes each parameter.
Find command name,
./The path to be searched, that is, where to find it.
! This is also called the inverse.
-The "2" file appears in the "-name" search file. Including folders.
Find ./! -Name '* 2 *'
Create a shell script that receives 10 numbers and displays the maximum and minimum number of linuxs, which cannot be executed on the Internet.
#! /Bin/bash
Function usage ()
{
Echo "$0 N1 N2... N10"> & 2
Exit 1
}
[[$ #-Eq 10] | usage
Max = $1
Min = $1
Shift
For I in $ *
Do
[[$ Min-gt $ I] & min = $ I
[[$ I-gt $ max] & max = $ I
Done
Echo-e "Max = $ max \ tMin = $ min"