Linux命令行总结

时间:2021-02-05 10:44:11

1.修改同一目录下所有图片的尺寸(宽x高)

长宽比不变&长宽比改变

find ./ -name '*.jpg' -exec convert -resize 600x480 {} {} \;
find ./ -name '*.jpg' -exec convert -resize 600x480 !{} {} \;

2.生成同一目录下所有图片的路径

ls *.jpg > list.txt
ls */train/depths/*.png > depth.txt

3.压缩和解压缩

zip 命令: 
# zip test.zip test.txt 
它会将 test.txt 文件压缩为 test.zip ,当然也可以指定压缩包的目录,例如 /root/test.zip 
# unzip test.zip 
它会默认将文件解压到当前目录,如果要解压到指定目录,可以加上 -d 选项

# unzip test.zip -d /root/

解压文件中的部分文件

# unzip test.zip 'part1/*' -d target_dir

未完待续。。。