Shell BASICS (10) including shell scripts and shell Basics

Source: Internet
Author: User

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"

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.