the funnygame.sh
make a shell script that contains the usage of ls & cd & mkdir & touch & nano & cp & mv & rm & asterisk & question mark & alias
#the funnygame.sh script content
GNU nano 2.9.8 funnygame.sh Modified
#This is a big game
#!/bin/bash
mkdir -pv ./rubbish/waste00/garbage00/hiahia.haha/
touch hiahiahia.hahaha
nano hiahiahia.hahaha
cp ./rubbish/waste00/garbage00/hiahia.haha/hiahiahia.hahaha ./rubbish/
cp ./rubbish/waste00/garbage00/hiahia.haha/hiahiahia.hahaha ./rubbish/waste00/
cp ./rubbish/waste00/garbage00/hiahia.haha/hiahiahia.hahaha ./rubbish/waste00/g$
cp ./rubbish/waste00/garbage00/hiahia.haha/hiahiahia.hahaha ./rubbish/waste00/g$
ls ./rubbish/waste00/garbage00/hiahia.haha
ls ./rubbish/waste00/garbage00/
ls ./rubbish/waste00/
ls ./rubbish
mv ./rubbish/hiahiahia.hahaha ./
mv ./rubbish/waste00/hiahiahia.hahaha ./
mv ./rubbish/waste00/garbage00/hiahiahia.hahaha ./
^G Get Help ^O Write Out ^W Where Is ^K Cut Text ^J Justify ^C Cur Pos
^X Exit ^R Read File ^\ Replace ^U Uncut Text^T To Linter ^_ Go To Line
#practice
[kingarthur@localhost ~]$ pwd
/home/kingarthur
[kingarthur@localhost ~]$ cd ./Documents/Unix_and_perl_primer/
[kingarthur@localhost Unix_and_perl_primer]$ ls
cp_rm hello_world ls_cd_mkdir
[kingarthur@localhost Unix_and_perl_primer]$ mkdir alias
[kingarthur@localhost Unix_and_perl_primer]$ cd alias/
#the usage of command mv
[kingarthur@localhost alias]$ mv ../hello_world/ ./
[kingarthur@localhost alias]$ ls
hello_world
[kingarthur@localhost alias]$ ls ../
alias cp_rm ls_cd_mkdir
[kingarthur@localhost alias]$ mv ./hello_world/ ../
[kingarthur@localhost alias]$ ls
[kingarthur@localhost alias]$ ls ../
alias cp_rm hello_world ls_cd_mkdir
#the usage of command chmod
[kingarthur@localhost alias]$ touch authority.txt
[kingarthur@localhost alias]$ ls -l authority.txt
-rw-rw-r--. 1 kingarthur kingarthur 0 Mar 6 04:05 authority.txt
[kingarthur@localhost alias]$ touch helloA.sh
[kingarthur@localhost alias]$ ls -l
total 0
-rw-rw-r--. 1 kingarthur kingarthur 0 Mar 6 04:05 authority.txt
-rw-rw-r--. 1 kingarthur kingarthur 0 Mar 6 04:06 helloA.sh
[kingarthur@localhost alias]$ chmod u+x helloA.sh
[kingarthur@localhost alias]$ ls -l
total 0
-rw-rw-r--. 1 kingarthur kingarthur 0 Mar 6 04:05 authority.txt
-rwxrw-r--. 1 kingarthur kingarthur 0 Mar 6 04:06 helloA.sh
#the first character - means docu, if d means direc, the second to forth means the authority of file owner' s read/write/execute, the fifth to seventh means the authority of groups, the eights to tenth means the authority of other users.
#r=4, w=2, x=1
[kingarthur@localhost alias]$ chmod 664 helloA.sh
[kingarthur@localhost alias]$ ls -l
total 0
-rw-rw-r--. 1 kingarthur kingarthur 0 Mar 6 04:05 authority.txt
-rw-rw-r--. 1 kingarthur kingarthur 0 Mar 6 04:06 helloA.sh
[kingarthur@localhost alias]$ man rm
[kingarthur@localhost alias]$ rm helloA.sh
[kingarthur@localhost alias]$ ls
authority.txt
#usage of command touch/nano/rm/less/shell script
[kingarthur@localhost alias]$ touch rubbish00.1 rubbish01.1 rubbish02.1 rubbish03.1
[kingarthur@localhost alias]$ nano cleanup.sh
[kingarthur@localhost alias]$ less cleanup.sh
[kingarthur@localhost alias]$ . cleanup.sh
rm: remove regular empty file 'rubbish01.1'? y
removed 'rubbish01.1'
rm: cannot remove 'ru?.1': No such file or directory
rm: cannot remove '*.faq': No such file or directory
[kingarthur@localhost alias]$ ls
authority.txt cleanup.sh rubbish00.1 rubbish02.1 rubbish03.1
#usage of command mkdir/mkdir -p
[kingarthur@localhost alias]$ mkdir ./rubbish/waste/garbage/hiahia.haha
mkdir: cannot create directory ‘./rubbish/waste/garbage/hiahia.haha’: No such file or directory
[kingarthur@localhost alias]$ mkdir -p ./rubbish/waste/garbage/hiahia.haha
[kingarthur@localhost alias]$ ls -l rubbish/waste/garbage/hiahia.haha
total 0
[kingarthur@localhost alias]$ ls -l rubbish/waste/garbage/
total 0
drwxrwxr-x. 2 kingarthur kingarthur 6 Mar 6 04:43 hiahia.haha
#Here comes the game, though failed , but find the bug, funnygame.sh command refering to direc which is Wrong make nosense.
[kingarthur@localhost alias]$ touch funnygame.sh
[kingarthur@localhost alias]$ nano funnygame.sh
[kingarthur@localhost alias]$ less funnygame.sh
[kingarthur@localhost alias]$ ls
authority.txt cleanup.sh funnygame.sh rubbish rubbish00.1 rubbish02.1 rubbish03.1
#cp, not copy
[kingarthur@localhost alias]$ . funnygame.sh
bash: copy: command not found...
bash: copy: command not found...
bash: copy: command not found...
bash: copy: command not found...
hiahia.haha
garbage00
waste waste00
mv: cannot stat './rubbish/hiahiahia.hahaha': No such file or directory
mv: cannot stat './rubbish/waste00/hiahiahia.hahaha': No such file or directory
mv: cannot stat './rubbish/waste00/garbage00/hiahiahia.hahaha': No such file or directory
mv: cannot stat './rubbish/waste00/garbage00/hiahia.haha/hiahiahia.hahaha': No such file or directory
hiahia.haha
garbage00
waste waste00
rm: remove regular empty file './hiahiahia.hahaha'? N
authority.txt cleanup.sh funnygame.sh hiahiahia.hahaha rubbish rubbish00.1 rubbish02.1 rubbish03.1
[kingarthur@localhost Documents]$ cd Unix_and_perl_primer/alias/
欢迎各位生信工作者、生信初学者和有志于转行生信领域的伙伴,关注微信公众号(ID: biomather),每天发布实验源代码,供大家学习交流使用。
公众号二维码,欢迎关注: