Shell variables, environment variable configuration files, pipe breaks

Source: Internet
Author: User

ENV View variable set also view variable content more powerful than env

[[email protected] ~]# echo $HOSTNAME See the name of the variable

Binbinlinux

[Email protected] ~]# a=1;b=2

[[email protected] ~]# echo $a $b can output a value of two variables

0 S

Variable names cannot begin with a number the name of the variable cannot be used by the name of the system command

[[email protected] ~]# c= ' ls/tmp/' for example this has a space special character with ' ' ' cause

[Email protected] ~]# echo $c

ls/tmp/

[[email protected] ~]# cyvim= ' which vim ' would like to have him automatically get the result of this command to add an anti-quote

[Email protected] ~]# echo $cyvim

/usr/bin/vim

[Email protected] ~]# a=1

[[email protected] ~]# c= "$a" is separated by double quotation marks or the default A is a variable name .

[Email protected] ~]# echo $c

112

[Email protected] ~]# echo $a

1

[[email protected] ~]# bash child shell

[[Email protected] ~]# exit child Shell

Exit

[[email protected] ~]# Export a=1 Global statement

[[email protected] ~]# bash into the child shell

[Email protected] ~]# echo $a

1

[[email protected] ~]# vim/etc/profile Add a custom variable to the configuration file

[Email protected] ~]# echo $c

1

[[email protected] ~]# unset c Cancel variable value unset

[Email protected] ~]# Vim/etc/profile

[[email protected] ~]# vim/etc/profile.d/path.sh defined path

#!/bin/bash

Export path= $PATH:/tmp/Global Declaration path= $PATH:/tmp/

~

Source/etc/profile immediate effect

[Email protected] ~]# echo $PATH you'll find a little more/tmp/.

/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/tmp/:/root/bin:/tmp/

[Email protected] ~]# echo $PATH

/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/tmp/:/root/bin:/tmp/

[[Email protected] ~]# Modify PATH

path=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/tmp/

[[email protected] ~]# Source/etc/profile effective

[[email protected] ~]# echo $PATH view

/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/tmp/:/tmp/

[Email protected] ~]# echo $PS 1

[\[email protected]\h \w]\$

[[email protected] ~]# ps1= ' [\[email protected]\h \w]\$ ' Modify PS1

[[email protected] ~]# ps1= ' [\[email protected]\h \w]\$ '

[[Email protected] ~] #cd/etc/init.d/

[[email protected]/etc/init.d] #PS1 = ' [\[email protected]\h \t\w]\$ '

[[email protected] 18:21:02/etc/init.d] #PS1 = ' [\[email protected]\h-\t\w]\$ '

[[email protected] 18:21:18/etc/init.d] #PS1 = ' [\[email protected]\h\w]\$ '

[[email protected]] #cd

[Email protected]~] #echo $PS 1

[\[email protected]\h\w]\$

vim/etc/profile.d/umask.sh Modify umask configuration file to 0023

Umask 0023

Then the Source/etc/profile declaration takes effect

Customizing profile environment variables for users themselves

Vim. Bash_profile definition

Vim. BASHRC Alias for user



[[email protected] ~]# ls *.txt wildcard * Can be multiple digits can be listed * below the number of digits *.txt

1.txt c.txt M.txt Z.txt

[email protected] ~]# ls?. Txt? Thought you could list the. txt

1.txt c.txt M.txt Z.txt

#号注释 comment does not take effect

\ de-Justification symbol

[email protected] ~]# ls #1. txt executes the LS command #号把后面注释了

Install.log M.txt

[[email protected] ~]# ls \ #1. txt you can get the # number off the back.

LS: Unable to access #1.txt: No file or directory

[[email protected] ~]# cat 1.txt |wc-l Throw the results of this command to the back of the day.

460

[[email protected] ~]# echo $PATH $ is a variable prefix

/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/tmp/:/data/bin:/root/bin

! $ go to execute this command at a time

[email protected] ~]# ls 1.txt; LS P.txt write a line of two commands; separate the numbers.

1.txt

~ Indicates the user's home directory

[[email protected] ~]# ls ~ equivalent to ls/root/

Install.log M.txt

[[email protected] ~]# Sleep & & Throw a command backstage.

[1] 1701

[[email protected] ~]# jobs is running

[1]+ Running Sleep &

[[email protected] ~]# jobs

[1]+ done Sleep 10

[[Email protected] ~]# > redirect >> Chase-weighted redirect 2> error redirect 2>> error append redirect

[[email protected] ~]# Wc-l <1.txt < reverse redirect

460

[[email protected] ~]# ls [1-9a-za-z].txt brackets indicate range such as 1-9 can be all listed

1.txt 2.txt c.txt m.txt z.txt


This article is from the "11325852" blog, please be sure to keep this source http://11335852.blog.51cto.com/11325852/1982678

Shell variables, environment variable configuration files, pipe breaks

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.