Shell Custom Variables

Source: Internet
Author: User

Print variables

[Email protected] shell]# echo $PATH/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

Custom variables

[[email protected] shell]# a=1 custom variable [[email protected] shell]# echo $a print variable 1

Write a script for user interaction

[[email protected] shell]# vim 2.sh#!/bin/bash### #read-P "Please input a number:" Number interaction is with Read-pecho $number [[EMA Il protected] shell]# sh 2.shplease input a number:1212

Wait five seconds to automatically exit without executing

[Email protected] shell]# vim 2.sh#!/bin/bash### #read-t 5-p "Please input a number:" Numberecho $number [email protect Ed] shell]# sh 2.sh Five seconds will automatically exit please input a number:[[email protected] shell]#

Mathematical operations

[[email protected] shell]# a=1;b=2[[email protected] shell]# c=$[$a + $b][[email protected] shell]# echo $c 3

Built-in variables

[Email protected] shell]# vim 3.sh#!/bin/bash### #echo "\$1=$1" echo "\$2=$2" echo "\$3=$3" [[email protected] shell]# SH 3. Sh$1=$2=$3=[[email protected] shell]# sh 3.sh 11 22 33$1=11$2=22$3=33








This article is from "Linux rookie" blog, please be sure to keep this source http://490617581.blog.51cto.com/11186315/1764413

Shell Custom Variables

Related Article

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.