ls命令-a/l/p 参数;alias 命令行运用;空目录与非空目录的复制/移动/重命名/彻底移除
#make dir for "mv" "rm" "alias"
[kingarthur@localhost ~]$ ls
Desktop Documents Downloads Music Pictures Public Templates Videos
[kingarthur@localhost ~]$ cd /home/kingarthur/Documents/Unix_and_perl_primer/
[kingarthur@localhost Unix_and_perl_primer]$ ls
hello_world ls_cd_mkdir
[kingarthur@localhost Unix_and_perl_primer]$ pwd
/home/kingarthur/Documents/Unix_and_perl_primer
[kingarthur@localhost Unix_and_perl_primer]$ ls
hello_world ls_cd_mkdir
#rm can remove dir(empty& unempty) and & or files ?
#the dir can also has "suffix"
[kingarthur@localhost Unix_and_perl_primer]$ mkdir test.csv
[kingarthur@localhost Unix_and_perl_primer]$ ls
hello_world ls_cd_mkdir test.csv
#directly remove the dir ?
[kingarthur@localhost Unix_and_perl_primer]$ rm test.csv
rm: cannot remove 'test.csv': Is a directory
[kingarthur@localhost Unix_and_perl_primer]$ clear
[kingarthur@localhost Unix_and_perl_primer]$ man mkdir
[kingarthur@localhost Unix_and_perl_primer]$ mkdir Iou.mp3
[kingarthur@localhost Unix_and_perl_primer]$ ls
hello_world Iou.mp3 ls_cd_mkdir test.csv
[kingarthur@localhost Unix_and_perl_primer]$ cd Iou.mp3/
#the dir can really has a "suffix"
[kingarthur@localhost Iou.mp3]$ cd ..
[kingarthur@localhost Unix_and_perl_primer]$ ls
hello_world Iou.mp3 ls_cd_mkdir test.csv
[kingarthur@localhost Unix_and_perl_primer]$ rm Iou.mp3/
#the dir can't be removed directly
rm: cannot remove 'Iou.mp3/': Is a directory
[kingarthur@localhost Unix_and_perl_primer]$ man rm
[kingarthur@localhost Unix_and_perl_primer]$ ls
hello_world Iou.mp3 ls_cd_mkdir test.csv
#-d means dir , -v means telling what have done
[kingarthur@localhost Unix_and_perl_primer]$ rm -d -v Iou.mp3/
removed directory 'Iou.mp3/'
[kingarthur@localhost Unix_and_perl_primer]$ ls
hello_world ls_cd_mkdir test.csv
[kingarthur@localhost Unix_and_perl_primer]$ man rm
[kingarthur@localhost Unix_and_perl_primer]$ ls ./test.csv/
[kingarthur@localhost Unix_and_perl_primer]$ ls
hello_world ls_cd_mkdir test.csv
[kingarthur@localhost Unix_and_perl_primer]$ cd test.csv/
[kingarthur@localhost test.csv]$ ls
#-r means recursive, to test the usage of it
[kingarthur@localhost test.csv]$ mkdir test_rm_dir_recursive.tst
[kingarthur@localhost test.csv]$ ls
test_rm_dir_recursive.tst
[kingarthur@localhost test.csv]$ cd test_rm_dir_recursive.tst/
[kingarthur@localhost test_rm_dir_recursive.tst]$ touch test.txt
[kingarthur@localhost test_rm_dir_recursive.tst]$ ls
test.txt
[kingarthur@localhost test_rm_dir_recursive.tst]$ cd ../..
[kingarthur@localhost Unix_and_perl_primer]$ pwd
/home/kingarthur/Documents/Unix_and_perl_primer
#-r means recursive
[kingarthur@localhost Unix_and_perl_primer]$ rm -d -r -v test.csv/
removed 'test.csv/test_rm_dir_recursive.tst/test.txt'
removed directory 'test.csv/test_rm_dir_recursive.tst'
removed directory 'test.csv/'
#move dir test.csv and the inner dir or files successfully
[kingarthur@localhost Unix_and_perl_primer]$ ls
hello_world ls_cd_mkdir
[kingarthur@localhost Unix_and_perl_primer]$ ls
hello_world ls_cd_mkdir
[kingarthur@localhost Unix_and_perl_primer]$ cd ls_cd_mkdir/
[kingarthur@localhost ls_cd_mkdir]$ ls
ahead_of_num behind_of_num empty_dir f_ques_mark_test num_asterisk_test unempty_dir
#-i means interaction
[kingarthur@localhost ls_cd_mkdir]$ rm -i -v unempty_dir/
rm: cannot remove 'unempty_dir/': Is a directory
#can't remove the unempty dir
[kingarthur@localhost ls_cd_mkdir]$ rm -iv -d unempty_dir/
rm: cannot remove 'unempty_dir/': Directory not empty
[kingarthur@localhost ls_cd_mkdir]$ rm -iv -d empty_dir/
rm: remove directory 'empty_dir/'? Y
removed directory 'empty_dir/'
#-r can help remove the unempty dir
[kingarthur@localhost ls_cd_mkdir]$ rm -ivrd unempty_dir/
rm: descend into directory 'unempty_dir/'? y
rm: remove regular empty file 'unempty_dir/test'? n
rm: remove regular empty file 'unempty_dir/test00.mp3'? n
rm: remove regular empty file 'unempty_dir/test01.mp3'? n
rm: remove regular empty file 'unempty_dir/test02.mp3'? y
removed 'unempty_dir/test02.mp3'
rm: remove regular empty file 'unempty_dir/test.mp3'? y
removed 'unempty_dir/test.mp3'
rm: descend into directory 'unempty_dir/txt'? n
rm: remove directory 'unempty_dir/txt.t'? n
[kingarthur@localhost ls_cd_mkdir]$ ls ./unempty_dir/
test test00.mp3 test01.mp3 txt txt.t
#test the function of "-r"
[kingarthur@localhost ls_cd_mkdir]$ rm -ivd ./unempty_dir/
rm: cannot remove './unempty_dir/': Directory not empty
[kingarthur@localhost ls_cd_mkdir]$ ls ./unempty_dir/
test test00.mp3 test01.mp3 txt txt.t
#test the function "-d"
#test the asterisk,but failed, the "."&".." was hidden
[kingarthur@localhost ls_cd_mkdir]$ rm -iv ./unempty_dir/.*
rm: cannot remove './unempty_dir/.': Is a directory
rm: cannot remove './unempty_dir/..': Is a directory
[kingarthur@localhost ls_cd_mkdir]$ rm -ivd ./unempty_dir/.*
rm: cannot remove './unempty_dir/.': Directory not empty
rm: cannot remove './unempty_dir/..': Directory not empty
[kingarthur@localhost ls_cd_mkdir]$ rm -ivdr ./unempty_dir/.*
rm: refusing to remove '.' or '..' directory: skipping './unempty_dir/.'
rm: refusing to remove '.' or '..' directory: skipping './unempty_dir/..'
[kingarthur@localhost ls_cd_mkdir]$ ls ./unempty_dir/
test test00.mp3 test01.mp3 txt txt.t
[kingarthur@localhost ls_cd_mkdir]$ rm -iv ./unempty_dir/*3
rm: remove regular empty file './unempty_dir/test00.mp3'? y
removed './unempty_dir/test00.mp3'
rm: remove regular empty file './unempty_dir/test01.mp3'? y
removed './unempty_dir/test01.mp3'
[kingarthur@localhost ls_cd_mkdir]$ ls
ahead_of_num behind_of_num f_ques_mark_test num_asterisk_test unempty_dir
[kingarthur@localhost ls_cd_mkdir]$ cd ..
[kingarthur@localhost Unix_and_perl_primer]$ ls
hello_world ls_cd_mkdir
[kingarthur@localhost Unix_and_perl_primer]$ mkdir cp_rm
[kingarthur@localhost Unix_and_perl_primer]$ cd cp_rm/
[kingarthur@localhost cp_rm]$ ls
[kingarthur@localhost cp_rm]$ cp ../ls_cd_mkdir/unempty_dir/*xt ./
cp: -r not specified; omitting directory '../ls_cd_mkdir/unempty_dir/txt'
[kingarthur@localhost cp_rm]$ ls ../ls_cd_mkdir/unempty_dir/
test txt txt.t
[kingarthur@localhost cp_rm]$ cp ../ls_cd_mkdir/unempty_dir/*xt ./
cp: -r not specified; omitting directory '../ls_cd_mkdir/unempty_dir/txt'
[kingarthur@localhost cp_rm]$ cp -r ../ls_cd_mkdir/unempty_dir/*xt ./
[kingarthur@localhost cp_rm]$ ls ./
txt
[kingarthur@localhost cp_rm]$ ls ../ls_cd_mkdir/unempty_dir/
test txt txt.t
#cp
[kingarthur@localhost cp_rm]$ man cp
[kingarthur@localhost cp_rm]$
[kingarthur@localhost cp_rm]$ less
Missing filename ("less --help" for help)
[kingarthur@localhost cp_rm]$ pwd
/home/kingarthur/Documents/Unix_and_perl_primer/cp_rm
[kingarthur@localhost cp_rm]$ cd ..
[kingarthur@localhost Unix_and_perl_primer]$ ls
cp_rm hello_world ls_cd_mkdir
#ls-p
[kingarthur@localhost Unix_and_perl_primer]$ ls -p
cp_rm/ hello_world/ ls_cd_mkdir/
#ls-l
[kingarthur@localhost Unix_and_perl_primer]$ ls -l
total 0
drwxrwxr-x. 3 kingarthur kingarthur 17 Mar 5 04:17 cp_rm
drwxrwxr-x. 2 kingarthur kingarthur 42 Mar 4 03:06 hello_world
drwxrwxr-x. 7 kingarthur kingarthur 115 Mar 5 03:58 ls_cd_mkdir
[kingarthur@localhost Unix_and_perl_primer]$ cd cp_rm/
[kingarthur@localhost cp_rm]$ ls ../ls_cd_mkdir/unempty_dir/
test txt txt.t
[kingarthur@localhost cp_rm]$ ls -l ../ls_cd_mkdir/unempty_dir/
total 0
-rw-rw-r--. 1 kingarthur kingarthur 0 Mar 4 03:31 test
drwxrwxr-x. 6 kingarthur kingarthur 81 Mar 4 05:05 txt
drwxrwxr-x. 2 kingarthur kingarthur 6 Mar 4 03:33 txt.t
[kingarthur@localhost cp_rm]$ ls -p ../ls_cd_mkdir/unempty_dir/
test txt/ txt.t/
#alias
[kingarthur@localhost cp_rm]$ alias ls = 'ls -p'
alias ls='ls --color=auto'
bash: alias: =: not found
bash: alias: ls -p: not found
[kingarthur@localhost cp_rm]$ ls
txt
[kingarthur@localhost cp_rm]$ ls ../ls_cd_mkdir/unempty_dir/
test txt txt.t
[kingarthur@localhost cp_rm]$ alias ls='ls -p'
[kingarthur@localhost cp_rm]$ ls ../ls_cd_mkdir/unempty_dir/
test txt/ txt.t/
[kingarthur@localhost cp_rm]$ ls /tmp
hsperfdata_root/
mozilla_kingarthur0/
systemd-private-486fb595972c456b95d625af87503685-bluetooth.service-4TExsS/
systemd-private-486fb595972c456b95d625af87503685-bolt.service-cxHTSB/
systemd-private-486fb595972c456b95d625af87503685-colord.service-SL0Hvp/
systemd-private-486fb595972c456b95d625af87503685-fwupd.service-oVRHmT/
systemd-private-486fb595972c456b95d625af87503685-ModemManager.service-AZs5X7/
systemd-private-486fb595972c456b95d625af87503685-rtkit-daemon.service-mH6xYC/
tracker-extract-files.1000/
[kingarthur@localhost cp_rm]$ alias rm='rm -iv'
[kingarthur@localhost cp_rm]$ rm ../ls_cd_mkdir/unempty_dir/*st
rm: remove regular empty file '../ls_cd_mkdir/unempty_dir/test'? y
removed '../ls_cd_mkdir/unempty_dir/test'
[kingarthur@localhost cp_rm]$ man rm
[kingarthur@localhost cp_rm]$ ls -a
./ ../ txt/
[kingarthur@localhost cp_rm]$ man chmod
[kingarthur@localhost cp_rm]$ man nano
[kingarthur@localhost cp_rm]$ man mv
[kingarthur@localhost cp_rm]$ man rm
[kingarthur@localhost cp_rm]$ pwd
/home/kingarthur/Documents/Unix_and_perl_primer/cp_rm
[kingarthur@localhost cp_rm]$ ls ../ls_cd_mkdir/unempty_dir/
txt/ txt.t/
[kingarthur@localhost cp_rm]$ mv ../ls_cd_mkdir/unempty_dir/txt.t
mv: missing destination file operand after '../ls_cd_mkdir/unempty_dir/txt.t'
Try 'mv --help' for more information.
[kingarthur@localhost cp_rm]$ mv ../ls_cd_mkdir/unempty_dir/txt.t ./
[kingarthur@localhost cp_rm]$ mv ../ls_cd_mkdir/unempty_dir/txt.t
mv: missing destination file operand after '../ls_cd_mkdir/unempty_dir/txt.t'
Try 'mv --help' for more information.
[kingarthur@localhost cp_rm]$ ls ../ls_cd_mkdir/unempty_dir/
txt/
[kingarthur@localhost cp_rm]$ ls ./
txt/ txt.t/
[kingarthur@localhost cp_rm]$
[kingarthur@localhost cp_rm]$ ls
txt/ txt.t/
[kingarthur@localhost cp_rm]$ ls -l
total 0
drwxrwxr-x. 6 kingarthur kingarthur 81 Mar 5 04:17 txt/
drwxrwxr-x. 2 kingarthur kingarthur 6 Mar 4 03:33 txt.t/
#ls-la
[kingarthur@localhost cp_rm]$ ls -la
total 0
drwxrwxr-x. 4 kingarthur kingarthur 30 Mar 5 05:07 ./
drwxrwxr-x. 5 kingarthur kingarthur 57 Mar 5 04:12 ../
drwxrwxr-x. 6 kingarthur kingarthur 81 Mar 5 04:17 txt/
drwxrwxr-x. 2 kingarthur kingarthur 6 Mar 4 03:33 txt.t/
欢迎各位生信工作者、生信初学者和有志于转行生信领域的伙伴,关注微信公众号(ID: biomather),每天发布实验源代码,供大家学习交流使用。
公众号二维码,欢迎关注: