Linux 小知识点

1:当前目录比较重要的几个文件

.
..
anaconda-ks.cfg
.bash_history
.bash_logout
.bash_profile
.bashrc
.cshrc
install.log
install.log.syslog
.tcshrc
.viminfo

2:设置环境变量 $PATH通常定义在/etc/profile 或~/.bashrc中

export   PATH="PATH:/home/user/bin" 
或者
PATH="PATH:/home/user/bin"   
export PATH

  

2:格式替换符号

printf "%-5s %-10s %-4s
" No Name Mark
printf "%-5s %-10s %-4.2f " 1 Sarath 80.3456

%-5s 指明了一个格式为左对齐且宽度为 5 的字符串替代(-表示左对齐)。如果不用-指定对齐方式,字符串则采用右对齐形式。

%- 4.2f, 其中.2 指定保留2个小数位注意在每行格式字符串后都有一个换行符 。

4:彩色打印

echo -e "e[1; 42m Green   Background e[0m"

要设置彩色背景,经常使用的颜色码是:重置= 0,黑色= 40,红色= 41,绿色= 42,黄色= 43, 蓝色= 44,洋红= 45,青色= 46,白色= 47。

5:获取某进程的环境变量

pgrep my #获取PID 例如为12500
cat /proc/12500/environ

  

原文地址:https://www.cnblogs.com/xiaoit/p/4064728.html