Shell Scripting Exercises

Source: Internet
Author: User

Shell common system Variable resolution: $ $ The name of the current script $n the nth parameter of the current script, n=1,2,... 9$* all parameters of the current script (excluding the program itself) $# the number of arguments to the current script (excluding the program itself) $? When a command or program finishes executing, a general return of 0 indicates a successful execution. $UID Current user's id$pwd current directory $$ is the current process ID number of the script run logical operator Resolution:-F to determine if the file exists eg:if [-f filename]-d determine if the directory exists eg:if [-D dir]-e Q equals applies To: integer comparison equal-ne not equal to: integer comparison not equal-lt less than applied: integer comparison letter-gt greater than applied: integer comparison greate-le less than or equal to: integral type comparison-ge greater than or equal to application In: integer comparison-A both are established (and) logical Expressions –a logical Expressions-o single-sided (or) logical expressions –o Logical Expressions-Z-empty strings



1 See which Shell you are currently using

[Email protected] conf]# echo $BASH/bin/bash

2 script +x to debug, troubleshoot errors

[[email protected] sh]#/bin/bash-x variable.sh + hellovariable.sh: line 2:hello: Command not found + a=123+ echo ' Print variables equal I S 123 ' Print variables equal is 123

3-E \ n line break

Echo-e "Start scripts. \ n .... "

4-E \033[32m \033[0m Promise color [32m can be changed to 33/34/35/36 color]

Echo-e "\033[32m start scripts. \n....\033[0m "

5 Linux commands, System built-in variables

[Email protected] sh]# echo $PWD/data/sh[[email protected] sh]# pwd/data/sh

6 $? The state after the command or program has finished executing, typically returning 0 for successful execution

[[email protected] sh]# Pwd/data/sh[[email protected] sh]# echo $?0[[email protected] sh]# sbash:s: Command not found [[email protect   ED] sh]# echo $? Indicates that the previous command failed to execute successfully 127


This article is from the "Drow blog" blog, please be sure to keep this source http://6874869.blog.51cto.com/6864869/1877940

Shell Scripting Exercises

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.