Shell Usage Tips

Source: Internet
Author: User

Skillfully using the delimiter delimiter

Where to enter large pieces of text

Automatic selection and entry of places

Accessing the database

[Email protected] ~cat > OUT.txt << EOF> 123jl412 3> o> EOF
Tool Usage Tips

Uniquely identifies

Date: Creates a log file as a file name using the date command.

$$: Creates a unique temporary file with the process number.

Send Signal

Signal

Signal Name

Meaning

0

EXIT

Exit signal (using exit, ctrl-d can be issued)

1

SIGHUP

Hangs or the parent process is killed

2

SIGINT

Interrupt signal from the keyboard, usually <CTRL-C>

3

Sigquit

Exit from keyboard

9

SIGKILL

Unconditional termination

11

SIGSEGV

Segment (memory) conflict

15

SIGTERM

Software termination (default kill process signal)

The signal can be sent using the following format (the default is 15):
Kill [-signal no:| signal name] process ID

You can use KILL-L to list all signals

Detection signal

Traps allow you to capture signals in the script. The general form of the command is:
Trap name Signal (s)

Common use of TRAP commands

Trap "" 2 3

Ignoring signal 2 and signal 3, the user cannot terminate the script

Trap "Commands" 2 3

If the signal 2 or 3 is captured, the corresponding commands command is executed

Trap 2 3

Reset signals 2 and 3, the user can terminate the script

Eval

Use the eval command to execute the command after the eval command.

Logger

Using the Logger command, you can write log to the message in the system's log directory (view/etc/syslog.conf's system settings).

The general form of the Logger command is:
Logger-p-I. Message

P is the priority, I is the process number

Shell Usage Tips

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.