bash基础特性一:补全

  1. 命令补全
    命令补全:若给出的字符能在系统命令文件中被唯一标识,则tab键直接补全,否则,会给出相应的列表
[root@host ~]# echo $PATH                      #查看当前的环境变量
	/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:
	[root@host ~]# cat /etc/shells
	/bin/sh
	/bin/bash
	/usr/bin/sh
	/usr/bin/bash
	[root@host ~]# echo $SHELL                    #当前系统默认的shell
	/bin/bash
配置环境变量的文件有:
		全局变量:/etc/bashrc ; /etc/profile
		用户变量:~/.bashrc ; ~/.bash_profile
例如:配置一个全局变量:hello 命令,显示:hello world
[root@host ~]# mkdir -p /test/test_bin/        #创建一个存放hello文件的目录
[root@host ~]# cd /test/test_bin/
[root@host test_bin]# touch hello           
[root@host test_bin]# chmod +x hello         #给hello文件赋权,可执行
[root@host test_bin]# vim hello
	 echo "hello world!"
root@host test_bin]# vim /etc/profile           #配置/etc/profile
	export PATH=$PATH:/test/test_bin          #在末尾找个位置加上这句就可以了
[root@host test_bin]# source /etc/profile     #source 一下/etc/profile 可以使这个文件立即生效不用重启
[root@host test_bin]# hel                             #此时已经可以用补全机制 获取到hello命令了
hello  help
[root@host test_bin]# hello
hello world!
[root@host ~]# he                                        #在root家目录也可以补全hello命令
head     hello    help     hexdump
[root@host ~]# echo $PATH                        #查看此时的环境变量,已经有/test/test_bin了
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/test/test_bin
  1. 路径补全
    路径补全:给出的路径字符,若能够被文件系统位移匹配,则直接补全,若存在多个,则给出相应列表
[root@host ~]# cat /etc/f     #给出的路径字符对应目录下查找,进行补全
favicon.png  filesystems  firewalld/   fonts/       fstab        fuse.conf

-------------------------------------------------------------------------------------------------------返回目录

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值