Shell-related usage

Source: Internet
Author: User

Shell-related usage

If usage

-Q does not output results, only make judgments

[Email protected] tmp]# if Grep-q ' ^daixuan: '/etc/passwd; Then echo "Daixuan text"; fi

, when/ETCPASSWD contains Daixuan, the output Daixuan test



Case usage

[Email protected] tmp]# vim case.sh

#/bin/bashread -p  "please input a number: "  nm=$[$n%2]echo  $mcase   $m  in        1)                  echo  "The number is jishu."                 ;;         0)                  echo  " the number is oushu."                 ;;         *)                  echo  "It is not jishu or oushu."                 ;; Esac


[Email protected] tmp]# sh case.sh

Please input a number:12

0

The number is Oushu.

[Email protected] tmp]# sh case.sh

Please input a number:11

1

The number is Jishu.

[Email protected] tmp]# sh case.sh

Please input a number:abcdef

0

The number is Oushu.



For usage

Use of SED

[[email protected] tmp]# SEQ 1 10

1

2

3

4

5

6

7

8

9

10

[[email protected] tmp]# SEQ 1 2 10

1

3

5

7

9

[[email protected] tmp]# seq 10-2 1

10

8

6

4

2

[Email protected] tmp]# Seq-w 1 10

01

02

03

04

05

06

07

08

09

10

[Email protected] tmp]# vim for.sh

#/bin/bashfor i in ' seq 1 ';d o echo $idone

[Email protected] tmp]# sh for.sh


This article is from the "Daixuan" blog, make sure to keep this source http://daixuan.blog.51cto.com/5426657/1739414

Shell-related usage

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.