Bài TH2 CT178 Nguyên lý hệ điều hành

6 7 0
Bài TH2 CT178  Nguyên lý hệ điều hành

Đang tải... (xem toàn văn)

Thông tin tài liệu

BaiTH02 Bài 1Bài 1 Ví dụ 1 In %%bash touch firstscript In clear echo This is my first script>firstscript In %%bash chmod 755 firstscript ls l firstscript Bài tập 1 In %%bash clea.

Bài Ví dụ In [ ]: %%bash touch firstscript In [ ]: clear echo "This is my first script!!!">firstscript In [ ]: %%bash chmod 755 firstscript ls -l /firstscript total -rwxr-xr-x root root 40 Apr 07:25 firstscript drwxr-xr-x root root 4096 Mar 23 14:22 sample_data This is my first script!!! Bài tập In [ ]: %%bash clear echo "Hello $USER" echo -e "Today is \c ";date echo -e "Number of user login : \c" ; who | wc -l echo -e "Calendar" cal exit Hello Today is Mon Apr 04:33:06 UTC 2022 Number of user login : Calendar April 2022 Su Mo Tu We Th Fr Sa _​ _​4 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 Bài tập In [ ]: %%bash myname=Vivek myos = TroubleOS myno=5 echo "My name is $myname" echo "My os is $myos" echo "My number is myno, can you see this number" My name is Vivek My os is My number is myno, can you see this number bash: line 2: myos: command not found Dòng bị lỗi Lý do: cách khai báo biến sai(Có khoảng trống bên dấu bằng) Bài tập In [ ]: %%bash expr + echo $? echo Welcome echo $? wildwest canwork ? echo $? date echo $? Welcome 127 Mon Apr 04:42:29 UTC 2022 bash: line 5: wildwest: command not found Ví dụ In [ ]: %%bash mkdir -p /root/shellscript/ touch /root/shellscript/hello In [ ]: %%bash chmod 775 /root/shellscript/hello sh /root/shellscript/hello Hello World!! Today is Mon Apr 05:58:26 UTC 2022 Ví dụ In [ ]: %%bash echo $BASH echo $PWD /bin/bash /content Ví dụ In [ ]: %%bash no=10 n=100 echo $no echo $n 10 100 Ví dụ In [ ]: %%bash No=99 no=10 vech= echo $No echo $no echo $vech n=66 echo $n echo "My name is $LOGNAME" 99 10 66 My name is Ví dụ In [ ]: %%bash echo -e "\t Khoa CNTT & TT \n\t Dai Hoc Can Tho" Khoa CNTT & TT Dai Hoc Can Tho Ví dụ In [ ]: %%bash expr + expr - expr 10 / expr 20 % expr 10 \* 30 Ví dụ In [ ]: %%bash echo "Tong cua va la: `expr + 3`" Tong cua va la: Ví dụ In [ ]: %%bash echo "Tong cua va la: `expr + 3`" echo "Tong cua va la: 'expr + 3'" echo "Tong cua va la: "expr + 3"" Tong cua va la: Tong cua va la: 'expr + 3' Tong cua va la: expr + Ví dụ 10 In [ ]: %%bash rm unknowfile echo $? rm: cannot remove 'unknowfile': No such file or directory Ví dụ 11 In [ ]: %%shell echo "Your first name please:" read ten echo "Hello, $ten, let's be friend!" Your first name please: Vu Phuong Hello, Vu Phuong, let's be friend! Out[ ]: In [ ]: %%bash echo "Today is:";date Today is: Mon Apr 07:32:40 UTC 2022 Ví dụ 12 In [ ]: %%bash touch demo chmod 755 demo In [ ]: %%bash /demo aa bb Total number of command line argument are /demo is script name aa is first argument bb is second argument All of them are: aa bb or aa bb Bài In [ ]: %%shell echo "\\ ****************************************\\ " echo date echo echo echo echo read echo echo "Today is:" "Hello $LOGNAME !!!" "Your current working directory: $PWD" "Your home directory: $HOME" "Please press any key to finish:" n " Thank you very much!!" "\\ ****************************************\\ " \****************************************\ Today is: Mon Apr 07:36:12 UTC 2022 Hello !!! Your current working directory: /content Your home directory: /root Please press any key to finish: Thank you very much!! \****************************************\ Out[ ]: Bài In [ ]: %%bash touch BAI_3 chmod 755 BAI_3 In [ ]: %%bash /BAI_3 Tham so ban da truyen vao la so: va Tong: + = 17 Hieu: – = -1 Tich: * = 72 Thuong: / = So du: % = Bài In [1]: %%bash touch taothumuc In [ ]: echo "Ten thu muc muon tao: " read tm mkdir $tm kq=$? if [ $kq -ne ] then echo "Khong the tao duoc thu muc $tm" fi In [2]: %%shell chmod 755 taothumuc /taothumuc Ten thu muc muon tao: Ten thu muc muon tao: Phuong Out[2]: Bài In [3]: %%bash touch thuchien In [ ]: $1 $2 status=$? if [ $status -ne ] then echo "Thuc thi khong cong!" else echo "Thuc thi cong!" fi In [4]: %%shell chmod 755 thuchien /thuchien mkdir thumuc1 Thuc thi cong! Out[4]:

Ngày đăng: 23/12/2022, 10:46

Tài liệu cùng người dùng

Tài liệu liên quan