常用linux 命令

new_note_001


#!/usr/local/bin/env python3.8

import sys

def main():
    print(' '.join(sys.argv[1:]))

if __name__=='__main__':
    main()

****chmod +x a.py ** **这样a.py就变成可执行文件, 上面那个环境就可以用到啦
还可以把 后缀.py 去掉

./test002.py
mv test002.py test002
./test002
都可以直接执行了

PATH=\(PATH:\)PWD

echo $PATH 读取PATH变量的值

~/Desktop 🔥» echo $PATH                                                            vivi@vivideMacBook-Pro
/usr/local/Cellar/gdb/8.2.1/bin:/usr/local/opt/freetds@0.91/bin:$/Library/Frameworks/Python.framework/Versions/3.6/bin:/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/Cellar/mysql/5.7.15/bin/:/Applications/apache-tomcat-8.5.23/bin:/usr/local/bin:JAVA_HOME/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Wireshark.app/Contents/MacOS

PATH=\(PATH:\)PWD 把当前环境加入PATH变量,这样就可以用 which test002来查找它啦
7 = 1(x) + 2(w) + 4(r)
可执行,可写,可读 x, w, r


ls -lt 时间倒序
ls -ltr 时间正序
ls -lS 大小倒序
ls -li 显示inode

cat smb_quicktest.py| grep -E 'form_re|my_sa|isi_simple'
-i 忽略大小写
[root@centos7 temp]# grep -i abcd file
ABCD
function abcd() {
[root@centos7 temp]#

选项-o表示只输出匹配的字符,而不是整行:
[root@centos7 temp]# grep -oi abcd file
ABCD
abcd
[root@centos7 temp]#
选项-c统计匹配的行数:
[root@centos7 temp]# grep -oic abcd file
2
[root@centos7 temp]#
选项-v表示取反匹配,如输出/etc/passwd中不以/sbin/nologin结尾的行:
[root@centos7 temp]# grep -v "/sbin/nologin$" /etc/passwd
root❌0:0:root:/root:/bin/bash
sync❌5:0:sync:/sbin:/bin/sync
shutdown❌6:0:shutdown:/sbin:/sbin/shutdown
halt❌7:0:halt:/sbin:/sbin/halt
learner❌1000:1000::/home/learner:/bin/bash
root@DTRDUCLI439077:/usr/local/ds_stress [master *%] # grep -v "rmdir" 111.txt

FAIL:: 4244:Sun 05/26/2019 14:02:42.747: create: \proto-g6-efsp01-t23.lorg.west.isilon.com\ifs\agefs_test_b2ee17c2-802d-11e9-99b2-005056900298\XPRO006-02\proto-g6-efsp01\smb_user_81\00000140\data\PSVZf7Qf4xO9EpiN6tcyZv\s.dip, expected=943616, actual=1014160, bs=235904, cnt=4, validated=0, coheren

选项-w表示匹配整个单词:
[root@centos7 temp]# grep here file
here
there
[root@centos7 temp]# grep -w here file
here
[root@centos7 temp]#
选项-n表示显示行号:
[root@centos7 temp]# grep -n "[1]" /etc/passwd
1:root❌0:0:root:/root:/bin/bash
5:lp❌4:7:lp:/var/spool/lpd:/sbin/nologin
24:learner❌1000:1000::/home/learner:/bin/bash
选项-A N、-B N、-C N表示输出匹配行和其'周围行'
-A N 表示输出匹配行和其之后(after)的N行
-B N 表示输出匹配行和其之前(before)的N行
-C N 表示输出匹配行和其之前之后各N行

统计出现success的次数
ali1-x0jjn6l-1# cat smb_quicktest.signing.log | grep -o success | grep -c success
367

文件夹下 文件夹的个数 recursive:
ls -lR|grep "^d"|wc -l

  1. rl ↩︎

posted @ 2019-11-10 16:49  vivi~  阅读(302)  评论(3编辑  收藏  举报