??????Щ????????????????????????????????????????????????????????????????????????????????“???”????????|????????????????????????stdout????
????????????????????????????????
????[root@localhost ~]
????# cat text_file.txt
????This line does not contain H e l l o word
????This lilne contains Hello
????This also containd Hello
????This one no due to HELLO all capital
????Hello bash world!
?????????????????????Щ????“Hello”???У?Linux???и?grep??????????ù?????
????[root@localhost ~]
????# grep Hello text_file.txt
????This lilne contains Hello
????This also containd Hello
????Hello bash world!
????[root@localhost ~]
????#
???????????и?????????????????????????????????????????????????????????????????в????Щ????????????????????????????????????????????????????????????????????
????[root@localhost ~]
????# fdisk -l>fdisk.out
????[root@localhost ~]
????# grep "Disk /dev" fdisk.out
????Disk /dev/sda: 8589 MB?? 8589934592 bytes
????Disk /dev/mapper/VolGroup-lv_root: 7205 MB?? 7205814272 bytes
????Disk /dev/mapper/VolGroup-lv_swap: 855 MB?? 855638016 bytes
????[root@localhost ~]
????#
????????????grep?Щ??????????????п??????????
???????fdisk???????????Linux???????????????????????
??????????????????????????????????????????????????????????????????????????????ù?????????????????????????????stdout????????????stdin????
????[root@localhost ~]
????# fdisk -l | grep "Disk /dev"
????Disk /dev/sda: 8589 MB?? 8589934592 bytes
????Disk /dev/mapper/VolGroup-lv_root: 7205 MB?? 7205814272 bytes
????Disk /dev/mapper/VolGroup-lv_swap: 855 MB?? 855638016 bytes
????[root@localhost ~]
????#
???????????????????????κ??????????????????????????fdisk stdout???????grep stdin??
??????? ?? ?????????????????????
???????м????????????????????????????????潲??
??????shell?????????????
???????????????????????????shell????????shell???????????????????е????????????????Щ?????????????Щ???????????????????????????Щ????????????????????????????????
???????????????????????????????????????????????shell????????????????綽???????????????????????????????????Щ????洢???????????data.txt?У???????????????????????????????????????????????????????С?????????????????????????????????????????????????????????echo??printf??????????????????????????????printf????????????????????????????????????????????????????????????????????????????????????????????ɡ???????????????????????????????kate??nano??vi??……????????????note.sh???????????д????Щ????
????echo "Phone number ?"
???????????/??н????
????????????????????????bash?????????У???????????????????????
????[root@localhost ~]
????# bash note.sh
????Phone number ?
??????????????????н????????????????????bash?????????????У????????Щ????y??????У???????????chmod????
????[root@localhost ~]
????# ls -la note.sh
????-rw-r--r--. 1 root root 22 Apr 23 20:52 note.sh
????[root@localhost ~]
????# chmod +x note.sh
????[root@localhost ~]
????# ls -la note.sh
????-rwxr-xr-x. 1 root root 22 Apr 23 20:52 note.sh
????[root@localhost ~]
????#
??????? ?? ls??????????????????????????????-la???????????????????????
??????????????????chmod???????????????ж???r????д??w???????????chmod +x???????????У?x?????????????????????????????????????н???????????????????????????У?
????[root@localhost ~]
????# ./note.sh
????Phone number ?
???????????????????? ./ ????.(????unix????????ζ????λ??????????У???/??б?????????з?????????Windows???У???????÷?б?? ??????????????????????????????????“????????????note.sh???”?????????????????·?????????????????????????????Щ??
????[root@localhost ~]
????# /root/note.sh
????Phone number ?
????[root@localhost ~]
????#
??????????????
???????????linux???????????????shell????????OK??????????????иy???????????shell?????????????????????????????shell?????????????????????????????????????????????????bash????????????#!/bin/bash????????С??????????????shell??????/bin/bash??????????????????е?????????У?
????[root@localhost ~]
????# cat note.sh
????#!/bin/bash
????echo "Phone number ?"
????????????????????bash?????????????????????????????????
???????????
????????????????????????????и?read???????????????????
????#!/bin/bash
????echo "Phone number ?"
????read phone
????????к???????????????????????[ENTER]??????????
????[root@localhost ~]
????# ./note.sh
????Phone number ?
????12345 <--- ????????????????
????[root@localhost ~]
????#
??????????????ж????????洢??????phone?У????????????????????????????echo????
????[root@localhost ~]
????# cat note.sh
????#!/bin/bash
????echo "Phone number ?"
????read phone
????echo "You have entered $phone as a phone number"
????[root@localhost ~]
????# ./note.sh
????Phone number ?
????123456
????You have entered 123456 as a phone number
????[root@localhost ~]
????#
??????bash shell?У???????????$?????????????????????????????????????????????????????????????????$???????????????
?????????????????????????μ????????
????#!/bin/bash
????echo "Phone number?"
????read phone
????echo "Name?"
????read name
????echo "Issue?"
????read issue
????[root@localhost ~]
????# ./note.sh
????Phone number?
????123
????Name?
????Jim
????Issue?
????script is not working.
????[root@localhost ~]
????#
??????????????
???????????????????????????ж????????data.txt????????η?????????????/??б????????
??????? ?? ?????????κ?????????????????????????????????????Щ???????????????????????????в?????????Ρ?
?????????????“>>”??????“>”???????????????????????????????
????[root@localhost ~]
????# tail -2 note.sh
????read issue
????echo "$phone/$name/$issue">>data.txt
????[root@localhost ~]
????# ./note.sh
????Phone number?
????987
????Name?
????Jimmy
????Issue?
????Keybord issue.
????[root@localhost ~]
????# cat data.txt
????987/Jimmy/Keybord issue.
????[root@localhost ~]
????#
??????? ?? tail????????????????n?С?