Shell Learning Notes

Source: Internet
Author: User
Tags clear screen

    1. number of logged-in users: who | Wc-l
    2. See which users are logged on to the system : who
    3. 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

    1. # 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

    1. printf statement printf "I said '%s,%s1,%s2,%s3 ' \ n" This is my pen
    2. Clear Screen :Clear
    3. Echo input A text branch append to file cc11: echo-e "WERW\NSFSD" >>cc11
    4. Remove the ASCII carriage return from the Aa.txt file and write the contents to file.txt

# tr-d ' \ R ' < Aa.txt > file.txt

    1. 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

    1. turn off the ability to automatically print input characters Stty-echo
    2. reply to the function of automatically printing input characters stty Echo
    3. 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

    1. Automated Test Course Catalog
    2. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.