1,file命令作用,查看文件的类型
[email protected]:~$ dirname ./linux/rename/1.htm ./linux/rename [email protected]:~$ file ./linux/rename/1.htm ./linux/rename/1.htm: empty [email protected]:~$ echo ‘this is a html file‘ > ./linux/rename/1.htm [email protected]:~$ file ./linux/rename/1.htm ./linux/rename/1.htm: ASCII text [email protected]:~$ which ls /bin/ls [email protected]:~$ file /bin/ls /bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=d0bc0fb9b3f60f72bbad3c5a1d24c9e2a1fde775, stripped [email protected]:~$ file ./python/ for.py func3.py func5.py global2.py while1.py func2.py func4.py func.py global.py while.py [email protected]:~$ file ./python/for.py ./python/for.py: ASCII text [email protected]:~$ file ./python/ ./python/: directory
2,chown: 改变文件或者目录的用户和用户组
用法:chown [option] [owner]:[group] [file]
注意:
>:可以用.代替
>用户和组要真实存在
常用参数: -R,递归修改目录的用户和用户组
把两个字符的 以.html结尾的文件删除,剩下少一点的文件,比较好看结果
[email protected]:~/linux/rename$ ls 100.htm 19.htm 28.htm 37.htm 46.htm 55.htm 64.htm 73.htm 82.htm 91.htm 10.htm 1.htm 29.htm 38.htm 47.htm 56.htm 65.htm 74.htm 83.htm 92.htm 11.htm 20.htm 2.htm 39.htm 48.htm 57.htm 66.htm 75.htm 84.htm 93.htm 12.htm 21.htm 30.htm 3.htm 49.htm 58.htm 67.htm 76.htm 85.htm 94.htm 13.htm 22.htm 31.htm 40.htm 4.htm 59.htm 68.htm 77.htm 86.htm 95.htm 14.htm 23.htm 32.htm 41.htm 50.htm 5.htm 69.htm 78.htm 87.htm 96.htm 15.htm 24.htm 33.htm 42.htm 51.htm 60.htm 6.htm 79.htm 88.htm 97.htm 16.htm 25.htm 34.htm 43.htm 52.htm 61.htm 70.htm 7.htm 89.htm 98.htm 17.htm 26.htm 35.htm 44.htm 53.htm 62.htm 71.htm 80.htm 8.htm 99.htm 18.htm 27.htm 36.htm 45.htm 54.htm 63.htm 72.htm 81.htm 90.htm 9.htm [email protected]:~/linux/rename$ find . -name "??.htm" | xargs rm [email protected]:~/linux/rename$ ls 100.htm 1.htm 2.htm 3.htm 4.htm 5.htm 6.htm 7.htm 8.htm 9.htm
2,改变用户和组 需要root权限
[email protected]:/home/ghostwu/linux/rename# ls -l total 4 -rw-rw-r-- 1 ghostwu ghostwu 0 5月 8 22:24 100.htm -rw-rw-r-- 1 ghostwu ghostwu 20 5月 8 22:49 1.htm -rw-rw-r-- 1 ghostwu ghostwu 0 5月 8 22:24 2.htm -rw-rw-r-- 1 ghostwu ghostwu 0 5月 8 22:24 3.htm -rw-rw-r-- 1 ghostwu ghostwu 0 5月 8 22:24 4.htm -rw-rw-r-- 1 ghostwu ghostwu 0 5月 8 22:24 5.htm -rw-rw-r-- 1 ghostwu ghostwu 0 5月 8 22:24 6.htm -rw-rw-r-- 1 ghostwu ghostwu 0 5月 8 22:24 7.htm -rw-rw-r-- 1 ghostwu ghostwu 0 5月 8 22:24 8.htm -rw-rw-r-- 1 ghostwu ghostwu 0 5月 8 22:24 9.htm [email protected]:/home/ghostwu/linux/rename# chown root.root 1.htm [email protected]:/home/ghostwu/linux/rename# ls -l 1.htm -rw-rw-r-- 1 root root 20 5月 8 22:49 1.htm [email protected]:/home/ghostwu/linux/rename# chown root:root 2.htm [email protected]:/home/ghostwu/linux/rename# ls -l 2.htm -rw-rw-r-- 1 root root 0 5月 8 22:24 2.htm [email protected]:/home/ghostwu/linux/rename# mkdir -p a/{b,c} [email protected]:/home/ghostwu/linux/rename# tree a a ├── b └── c 2 directories, 0 files [email protected]:/home/ghostwu/linux/rename# man tree ro[email protected]:/home/ghostwu/linux/rename# tree -ug a a ├── [root root ] b └── [root root ] c 2 directories, 0 files [email protected]:/home/ghostwu/linux/rename# chown -R ghostwu.ghostwu a [email protected]:/home/ghostwu/linux/rename# tree -ug a a ├── [ghostwu ghostwu ] b └── [ghostwu ghostwu ] c 2 directories, 0 files [email protected]:/home/ghostwu/linux/rename# ls -ld a drwxr-xr-x 4 ghostwu ghostwu 4096 5月 8 23:01 a [email protected]:/home/ghostwu/linux/rename#
原文地址:https://www.cnblogs.com/ghostwu/p/9011632.html
时间: 2024-10-10 18:16:43