Article title: basic knowledge of Linux: simple shell writing. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Script
To create a shell script, you can start by editing an existing shell script. For example, pico writes a script that uses common options to run the tar command to unbind files downloaded from the Internet.
$ Pico untar
Because untar is not saved in the current path, it is created. Then, enter the following content:
#! /Bin/bash
Echo this is the script file $0
Echo untarring the file $1
# Calltar with options-zxvf (filter through gzip, extract, verbose, filename)
Tar-zxvf $1
You can use Key to save, use Key to exit pico.
The first line of the script indicates what shell is used to execute the script. it must start with "#", otherwise it will not be executed. Other rows starting with "#" are comments and won't be executed by shell.
$0, $1, $2... is the parameter passed to the shell script. assume that when you execute the script, the parameters a, B, and c. g are used:
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.