Skip to content

常用命令

计算文件数量

shell
ls |wc -w

查看当前目录总大小

shell
du -hc |grep total

计算文件大小

shell
du filename

查找文件(关键字) by contain keyword

shell
grep keyword ./ -r -n

# powershell
Get-ChildItem -Recurse -Filter *.py | Select-String -Pattern "rotation" | FT -AutoSize
Get-ChildItem -Recurse -Filter *.py | Where-Object {$_.Name -ne '__init__.py'} | Select-String -Pattern "rotation" | FT -AutoSize

查找文件(文件名) by filename keyword

shell
locate {keyword}
find / -type f -name *keyword*

# powershell
$i = 1
Get-ChildItem -Path . -Recurse -Filter docker-compose.yml |
    Where-Object {$_.GetType().Name -eq "FileInfo"} |
    Sort-Object LastWriteTime |
    ForEach-Object { 
        $_ | Select-Object @{Name="Index";Expression={$i}}, FullName, Length, LastWriteTime;
        $i++
    } | Format-Table Index, FullName, Length, LastWriteTime

use scp copy file from remote

shell
echo scp $(whoami)@$(ip -br a show eth0 | awk '{print $3}' | cut -d '/' -f 1):$(pwd)/$(ls | grep .tgz) $(ls | grep .tgz)

echo scp $(whoami)@$(curl -s ifconfig.me):$(pwd)/$(ls | grep .tgz) $(ls | grep .tgz)

Released under the MIT License.