一次创建多个目录
[[email protected] tmp]# mkdir -p /user/{folder1,folder2,folder3} [[email protected] tmp]# ls /user/ folder1 folder2 folder3
找出根目录下最大的10个目录,并按使用空间从大到小排序
[[email protected] ~]# du -a ./ | sort -nr | head -n 10 132380 ./ 132316 ./source 69916 ./source/ZendGuard-5_5_0.tar.gz 18720 ./source/xunzai.com_mysql-5.0.18.tar.gz 13732 ./source/php-5.4.11.tar.gz 6144 ./source/phpMyAdmin-3.5.6-all-languages.tar.gz 5996 ./source/httpd-2.4.3.tar.gz 5044 ./source/libxml2-2.9.0.tar.gz 1984 ./source/pcre-8.32.zip 1960 ./source/freetype-2.4.10.tar.gz
查看根目录下所有以“.”开头的文件
[[email protected] ~]# find ./ -name ".[^.]*" ./.bash_logout ./.bash_profile ./.bashrc ./.cshrc ./.tcshrc ./.cache ./.config ./.bash_history ./.xauth96WqtE ./.mysql_history ./.mysql_history.TMP ./.viminfo
修改文件或目录的时间戳
[[email protected] ~]# stat person.txt File: ?.erson.txt? Size: 74 Blocks: 8 IO Block: 4096 regular file Device: 803h/2051d Inode: 145535279 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Context: unconfined_u:object_r:admin_home_t:s0 Access: 2016-04-02 05:05:10.370059171 -0700 Modify: 2016-04-02 05:04:40.854898705 -0700 Change: 2016-04-02 05:04:40.913901033 -0700 Birth: - [[email protected] ~]# touch -t 201604052135 person.txt #格式为YYMMDDhhmm [[email protected] ~]# stat person.txt File: ?.erson.txt? Size: 74 Blocks: 8 IO Block: 4096 regular file Device: 803h/2051d Inode: 145535279 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Context: unconfined_u:object_r:admin_home_t:s0 Access: 2016-04-05 21:35:00.000000000 -0700 Modify: 2016-04-05 21:35:00.000000000 -0700 Change: 2016-04-05 06:36:16.304945163 -0700 Birth: -
快速备份一个文件:cp filename{,.bak}
[[email protected] ~]# ls anaconda-ks.cfg person.txt source [[email protected] ~]# cp person.txt{,.bak} [[email protected] ~]# ls anaconda-ks.cfg person.txt person.txt.bak source
进程运行到后台
[[email protected] ~]# Ctrl + z
进程运行到前台
[[email protected] ~]# fg
随机产生10位字符数的十六进制数
[[email protected] ~]# openssl rand -hex 10 c3e805e84074211cc698
将文件解压到新的目录
[[email protected] src]# ls apr-1.4.6.tar.gz libmcrypt-2.5.8.tar.gz apr-util-1.5.1.tar.gz libpng-1.5.14.tar.gz autoconf-2.69.tar.gz libxml2-2.9.0.tar.gz debug pcre-8.32.zip freetype-2.4.10.tar.gz php-5.4.11.tar.gz gd-2.0.35.tar.gz phpMyAdmin-3.5.6-all-languages.tar.gz httpd-2.4.3 xunzai.com_mysql-5.0.18.tar.gz httpd-2.4.3.tar.gz ZendGuard-5_5_0.tar.gz jpegsrc.v8b.tar.gz zlib-1.2.7.tar.gz kernels [[email protected] src]# tar zxvf apr-1.4.6.tar.gz -C /tmp/tmp/ apr-1.4.6/ apr-1.4.6/shmem/ apr-1.4.6/shmem/win32/ ………… [[email protected] src]# ls /tmp/tmp/ apr-1.4.6
将所有文件名中含有”txt”的文件移入“/tmp/tmp”目录
[[email protected] ~]# find -iname "*txt*" -exec mv -v {} /tmp/tmp/ \; ?./person.txt?.-> ?.tmp/tmp/person.txt? ?./person.txt.bak?.-> ?.tmp/tmp/person.txt.bak? [[email protected] ~]# ls /tmp/tmp/ apr-1.4.6 person.txt person.txt.bak
将任意一行开头为“#”的去除掉
[[email protected] ~]# cat a.txt This is the file #This is another file #This is the final file [[email protected] ~]# sed ‘2s/^#//‘ a.txt This is the file This is another file #This is the final file
时间: 2024-10-14 14:57:49