在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
如何计算当前目录下的文件数和目录数 # ls -l * |grep "^-"|wc -l ---- to count files # ls -l * |grep "^d"|wc -l ----- to count dir ls -F | grep /$ 或者 alias sub = "ls -F | grep /$"(linux) ls -l | grep "^d" 或者 ls -lL | grep "^d" (Solaris) head -5 /etc/passwd tail -10 /etc/passwd sed -n '5,10p' /etc/passwd 这样你就可以只查看文件的第5行到第10行。 $find . -type f -exec grep "the string you want find…" {} ; -print . `--shellp `--updates `--wu-ftpd-2.4 | `--doc | | `--examples | `--src | | `--config | | `--makefiles | `--support | | `--makefiles | | `--man | `--util 脚本如下: #!/bin/sh # dtree: Usage: dtree [any directory] dir=${1:-.} (cd $dir; pwd) find $dir -type d -print | sort -f | sed -e "s,^$1,," -e "/^$/d" -e "s,[^/]*/([^/]*)$,`----1," -e "s,[^/]*/,| ,g" cut -d: -f 1 /etc/passwd >; /tmp/users cut -c3-5 /etc/passwd #!/bin/bash # Encrypt file with vim if (test $# -lt 2) then echo Usage: decrypt password filename else vim -e -s -c ":set key=$1" -c ':wq' $2 echo "$2 encrypted." fi [weeder@SMTH weeder]$ for file in *.txt ; do encrypt test $file ; done test2.txt encrypted. test4.txt encrypted. test9.txt encrypted. kick.txt encrypted. echo "$2 encrypted." fi [weeder@SMTH weeder]$ for file in *.txt ; do encrypt test $file ; done test2.txt encrypted. test4.txt encrypted. test9.txt encrypted. kick.txt encrypted. too_old.txt encrypted. too_old_again.txt encrypted. bg5.txt encrypted. [weeder@SMTH weeder]$ program_name |tee logfile alluser: :include:/etc/mail/allusers awk -F: '$3 >; 100 { print $1 }' /etc/passwd >; /etc/mail/allusers ldd /bin/ls echo "---------------" who | awk '{print $2}' echo "---------------" read $TTY kill -9 ${K}=`ps -t $TTY | grep [0-9] | awk '{print $1}'` |
请发表评论