shell笔记
system
磁盤
磁盤空間使用情況df
查看文件或目錄大小du
掛載usb
sudo fdisk -l # Find what the drive is called e.g. /dev/sdb1 sudo mkdir /media/usb sudo mount /dev/sdb1 /media/usb sudo umount /media/usb# umount sudo umount /media/usbutils
awk
打印文件的第一列(域) awk '{print $1}' filename
打印文件的前兩列(域) awk '{print $1,$2}' filename
打印文本第一行 awk 'NR==1{print}' filename
打印文本第二行第一列 sed -n "2, 1p" filename | awk 'print $1'
tar
tar解壓到另一個目錄tar -xf archive.tar -C /target/directory
-x : Extract a tar ball.
-v : Verbose output or show progress while extracting files.
-f : Specify an archive or a tarball filename.
-j : Decompress and extract the contents of the compressed archive created by bzip2 program (tar.bz2 extension).
-z : Decompress and extract the contents of the compressed archive created by gzip program (tar.gz extension).
grammer
文件測試運算符
-f file 檢測文件是否是普通文件(既不是目錄,也不是設備文件),如果是,則返回 true。
-d file 檢測文件是否是目錄,如果是,則返回 true。
-p file 檢測文件是否是有名管道,如果是,則返回 true。
-r file 檢測文件是否可讀,如果是,則返回 true。
-w file 檢測文件是否可寫,如果是,則返回 true。
-x file 檢測文件是否可執行,如果是,則返回 true。
-s file 檢測文件是否為空(文件大小是否大于0),不為空返回 true。
-e file 檢測文件(包括目錄)是否存在,如果是,則返回 true。
字符串運算符
= 檢測兩個字符串是否相等,相等返回 true。
!= 檢測兩個字符串是否相等,不相等返回 true。
-z 檢測字符串長度是否為0,為0返回 true。
-n 檢測字符串長度是否為0,不為0返回 true。
str 檢測字符串是否為空,不為空返回 true。
總結
- 上一篇: 记录一下:调试了虹软的人脸识别sdk,存
- 下一篇: [Leedcode][JAVA][第88