Linux Shell命令
ls命令
查看目录下的非软链接文件(通过grep来排除),并且排除"."和".."目录(-A选项)
yuxuecheng@linux:~/shellSource> ls -AlR | grep -v '^l'
.:
total 8
-rwxr--r-- 1 yuxuecheng users 479 Sep 24 15:25 change_file_mode.sh
-rwxr-xr-x 1 yuxuecheng users 214 Apr 27 10:04 test.sh
yuxuecheng@linux:~/shellSource> ls -AlR
.:
total 8
-rwxr--r-- 1 yuxuecheng users 479 Sep 24 15:25 change_file_mode.sh
-rwxr-xr-x 1 yuxuecheng users 214 Apr 27 10:04 test.sh
lrwxrwxrwx 1 yuxuecheng users 7 Sep 24 15:50 test_link.sh -> test.sh
yuxuecheng@linux:~/shellSource>
通过正则表达式选取指定类型的文件:
yuxuecheng@linux:~/shellSource> ls -Al
total 8
-rwxr--r-- 1 yuxuecheng users 479 Sep 24 15:25 change_file_mode.sh
-rwxr-xr-x 1 yuxuecheng users 214 Apr 27 10:04 test.sh
lrwxrwxrwx 1 yuxuecheng users 7 Sep 24 15:50 test_link.sh -> test.sh
yuxuecheng@linux:~/shellSource> ls -F | grep '*$'
change_file_mode.sh*
test.sh*
yuxuecheng@linux:~/shellSource> ls -F | grep '@$'
test_link.sh@
yuxuecheng@linux:~/shellSource>
find命令
查找指定类型的文件
yuxuecheng@linux:~> ls -Al
total 148
-rw------- 1 yuxuecheng users 15049 Sep 24 12:39 .bash_history
-rw-r--r-- 1 yuxuecheng users 33 Nov 6 2014 .bash_profile
-rw-r--r-- 1 yuxuecheng users 1177 Nov 6 2014 .bashrc
-rw-r--r-- 1 yuxuecheng users 1637 Nov 6 2014 .emacs
drwxr-xr-x 2 yuxuecheng users 4096 Nov 6 2014 .fonts
-rw-r--r-- 1 yuxuecheng users 18251 Nov 6 2014 .gnu-emacs
-rw-r--r-- 1 yuxuecheng users 861 Nov 6 2014 .inputrc
-rw------- 1 yuxuecheng users 139 Sep 24 15:52 .lesshst
drwxr-xr-x 2 yuxuecheng users 4096 Nov 6 2014 .mozilla
-rw-r--r-- 1 yuxuecheng users 6043 Nov 6 2014 .muttrc
-rw-r--r-- 1 yuxuecheng users 1056 Nov 6 2014 .profile
-rw------- 1 yuxuecheng users 413 Apr 9 16:32 .pyhistory
drwx------ 2 yuxuecheng users 4096 Dec 19 2014 .ssh
-rw------- 1 yuxuecheng users 19870 Sep 24 15:26 .viminfo
-rw-r--r-- 1 yuxuecheng users 1483 Aug 14 12:11 .vimrc
-rw-r--r-- 1 yuxuecheng users 849 Nov 6 2014 .vimrc.bak
-rw-r--r-- 1 yuxuecheng users 1940 Nov 6 2014 .xim.template
-rwxr-xr-x 1 yuxuecheng users 1446 Nov 6 2014 .xinitrc.template
drwxr-xr-x 10 yuxuecheng users 4096 Aug 25 16:55 CSource
drwxr-xr-x 3 yuxuecheng users 4096 Mar 19 2015 bin
drwxr-xr-x 2 yuxuecheng users 4096 Feb 11 2015 luaSource
drwxr-xr-x 2 yuxuecheng users 4096 Apr 9 16:42 pythonSource
drwxr-xr-x 2 yuxuecheng users 4096 Nov 12 2014 rubySource
drwxr-xr-x 2 yuxuecheng users 4096 Sep 24 15:50 shellSource
-rw-r--r-- 1 yuxuecheng users 4 Sep 24 11:14 test.txt
yuxuecheng@linux:~> find . -maxdepth 1 -type d
.
./luaSource
./.mozilla
./shellSource
./.fonts
./pythonSource
./CSource
./.ssh
./rubySource
./bin
yuxuecheng@linux:~>