Summary of Shell variables in RHEL 6 Linux

Source: Internet
Author: User
Tags variables require linux

Environment variable Path:

[Root@localhost ~]# set//check to see local and global Variables 2 kinds

[Root@localhost ~]# env//View the system's Global environment variables

[Root@localhost ~]# echo $PATH//View system environment variable path

[root@localhost ~]# Export $PATH//You can also use export to view environment variable paths

[root@localhost ~]# export path= $PATH:/date///Temporarily add/date directory to environment variable path

If you want to reboot the host, you have to edit the environment configuration file Root/.bashec or/root/.bash_profile and/etc/profile files, you want to take immediate effect you can use the command:

Note:. bash_profile file Detachment system Current user effective

[Root@localhost ~]# Source Bash_profile

[Root@localhost ~]# Ls–a can view these 2 files

Execution of scripts:

SH script//This method script does not require executable permissions

./script//must have executable permissions

. Script//This method script does not require executable permissions

Distinguishing between local and global variables

[Root@localhost ~]# str=1000//local variable

[Root@localhost ~]# Echo $str

1000

To edit a script:

# Vim Bianliang.sh

#!/bin/bash

Echo $str

[Root@localhost ~]# bianliang.sh//Our defined variables, but not the output through the script

[root@localhost ~]# Export str//Add to global variable

[Root@localhost ~]# bianliang.sh//Use full OK again

1000

To completely clear a global variable:

# unset STR Clears global variables

#env can view all global variables

&& | | Usage of: (Comparison of parameters)

The following action will be performed if the && condition meets the requirements

|| The following action is performed if the condition does not meet the requirements

See if there are any/grub.conf files in the/ect directory, output Yes, no output No.

[Root@localhost ~]# [-f/etc/grub.conf] && echo yes | | Echo No

Yes

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.