管道符、作业控制、变量
2018-01-12 02:03
246 查看
管道符
将前一个命令的输出作为后一个命令的输入cat 1.txt|wc -l 显示 1.txt 行数,先查看内容,再统计行数
作业控制
bg 将当前程序或进程调取到后台运行(挂起)fg 将当期程序或进程调取到前台进行
jobs 查看后台被挂起的进程
ctrl +z 暂停当期进程
ctrl +c 结束当前进程
ps 查看系统进程数
kill 杀死系统进程(指定PID)
killall 杀死系统进程(指定名称)
变量
PATH HOME PWD LOGNAMEenv命令 获取系统预设的全部系统变量(系统变量默认都是大写的)
set 多了很多变量,并且包括用户自定义的变量
自定义变量
变量名规则:字母、数字下划线,首位不能为数字
变量中有特殊字符,千万记得要两边加单引号
[root@aminglinux01 ~]# a='a b c '
[root@aminglinux01 ~]# echo $a
a b c
[root@aminglinux01 ~]# a= "a b c d "
-bash: a b c d : 未找到命令
[root@aminglinux01 ~]# a= "a b c d"
-bash: a b c d: 未找到命令
[root@aminglinux01 ~]# a='a$bc'
[root@aminglinux01 ~]# echo $a
a$bc
变量的累加
这是个很有意思的例子
全局变量
(当前shell的子shell继承当前父shell,即孙子有儿子的样子,儿子有你的样子,但你爸爸不会有你的样子)[root@aminglinux01 ~]# export aming=linux #声明全局变量
[root@aminglinux01 ~]# echo $aming
linux
[root@aminglinux01 ~]# bash #进入子shell
[root@aminglinux01 ~]# echo aming
aming
[root@aminglinux01 ~]# export aming=linux #进子shell的子shell
[root@aminglinux01 ~]# bash
[root@aminglinux01 ~]# echo aming
aming #子shell 均可生效
取消全局变量
[root@aminglinux01 ~]# unset aming[root@aminglinux01 ~]# echo $aming #取消后不生效
环境变量配置文件
/etc/profile 用户环境变量,交互、登录才执行/etc/bashrc 用户不登录,执行shell 就生效
只针对当前用户下的变量:
~/.bashrc
~/.bash_profile
~/.bash_history 用户历史记录记录
~/.bash_logout 用户退出需要做的操作
vim .bash_profile
. .bash_profile 或者 source .bash_profile使用户的.bash_profileshengxiao
===>会去自动调用 .bashrc===========>再会去自动调用/etc/bashrc
vim /etc/bashrc 配置PS1
PS1 显示用户登录时的信息
[root@aminglinux01 ~]# cd /etc/sysconfig/network-scripts/
[root@aminglinux01 network-scripts]# echo $PS1
[\u@\h \W]\$ # 当前用户,主机名,相对路径
相关文章推荐
- 管道符和作业控制、shell变量、环境变量配置文件
- 管道符和作业控制、shell变量和环境变量配置文件
- 管道符和作业控制、shell变量、环境变量配置文件
- 管道符和作业控制、shell变量、环境变量配置文件
- 管道符和作业控制、 shell变量 、环境变量配置文件
- 管道符和作业控制 shell变量 环境变量配置文件
- 管道符和作业控制 shell变量
- 2018-1-11 5周4次课 管道符、作业控制、shell变量、环境变量配置
- 管道符和作业控制、shell变量、环境变量配置文件
- 管道符和作业控制,shell变量,环境变量配置文件
- 管道符、作业控制、变量、定义全局变量、环境变量
- 8.6 管道符和作业控制;8.7—8.8 shell变量(上下);8.9 环境变量配置文件
- 管道符和作业控制、shell变量、环境变量配置文件、添加操作记录审计
- 8.6 管道符和作业控制 8.7/8.8 shell变量 8.9 环境变量配置文件
- 11.16 管道符和作业控制 , shell变量 , 环境变量配置文件
- 管道符,作业控制,shell变量,全局变量,环境变量的配置文件
- 8.6 管道符和作业控制 8.7/8.8 shell变量 8.9 环境变量配置文件
- 管道符和作业控制 shell变量 环境变量配置文件
- 管道符和作业控制 shell变量 环境变量配置文件
- 8.6-8.9 管道符和作业控制、shell变量,环境变量