- number of logged-in users: who | Wc-l
- See which users are logged on to the system : who
- Create a new file /bin/ct11, enter a command in the file,chmod Set the Execute permission for the file
# cat >/bin/ct11
W.H.O. | Wc-l
Press Ctrl+d
# Cd/bin
# chmod +x ct11
#./ct11
Execution Result:
2
- # echo escape sequence:
\c : Indicates that echo does not print the last line break symbol
\a : Warning character, usually the BEL character of ASCII
\b : Backspace
\f : Page Change
\ n : line break
\ r: Enter
\ t: Horizontal tab
\v: Vertical tab
\ \ : backslash character
\ODDD: Converts a character into a 3 -bit octal value
- printf statement printf "I said '%s,%s1,%s2,%s3 ' \ n" This is my pen
- Clear Screen :Clear
- Echo input A text branch append to file cc11: echo-e "WERW\NSFSD" >>cc11
- Remove the ASCII carriage return from the Aa.txt file and write the contents to file.txt
# tr-d ' \ R ' < Aa.txt > file.txt
- Remove the carriage return from the Aa.txt file and then use the pipeline to sort its file contents and enter it into the file file.txt
# tr-d ' \ r ' <aa.txt | Sort >file.txt
- turn off the ability to automatically print input characters Stty-echo
- reply to the function of automatically printing input characters stty Echo
- trace function set-x is to perform trace function open,set +x is turn off tracking function
Eg:cat > aa.sh
Set-x
Echo SS Echo
Set +x
Echo SDF Echo
Ctrl +d
Chmod +x aa.sh
./aa.sh Execution
- Automated Test Course Catalog
- Shell Pass Parameters
Create a new tst.sh script,
Nano-w tst.sh
The contents of the edit script are as follows, and then the first second parameter, and so on, is the file name parameter
#!/bin/sh
Name=$1
echo "My name is ${name}!"
Save Ctrl +o When edit is finished, Ctrl + C when exiting
Chmod +x tst.sh has execute permission for script
./tst.sh Zhang
Execution Result:
My name is Zhang
if it is vi mode edit mode press i, save and exit press ESC: wq!
17.
Shell Learning Notes