Chapter 6 of linuxshell programming guide ------ shell embedded commands

Source: Internet
Author: User
In fact, many shell embedded commands have been used. You may want to think about shell embedding. these commands are created in the actual Bourneshell instead of in the bin or usrbin directory. Embedded commands are faster than the same commands in the system.

In fact, many shell embedded commands have been used. It may be necessary to think about shell embedding. these commands are created in the actual Bourne shell instead of in the/bin or usr/bin directory. Embedded commands are faster than the same commands in the system.

This chapter includes:

Standard Bourne shell embedded command list

For example, the cd and pwd commands can be found in both the system and embedded commands. To run the system version, simply enter the command path:
/Bin/pwd

The set command was used to view the debugging script, enable or disable the shell option. Set can also be used to provide its running parameters within the script. The following is an example. Assume that a script controls two parameters, but does not pass the parameters to the script, but sets the values inside the script. You can use the set command to complete this function.
Format:
Set param1 param2 ..

The following script is set to accounts.doc and accounts. bak, and then the parameters are processed cyclically.
[Root @ localhost huangcd] #./set_ex
Accounts.doc
Accounts. bak
[Root @ localhost huangcd] # cat set_ex
#! /Bin/bash
Set accounts.doc accounts. bak
While [$ #! = 0]
Do
Echo $1
Shift
Done

The times Command provides the running time of user scripts or any system commands. The first line shows the shell consumption time, and the second line shows the time consumed by running the command. The output result of the times command is as follows:
[Root @ localhost huangcd] # times
0m0. 056 s 0m0. 125 s
0m0. 630 s 0m0. 599 s

Use t y p e to query whether the command still resides in the system and the command type. Type indicates whether the command name is valid and where the command is located. For example:
[Root @ localhost huangcd] # type mayday
Bash: type: mayday: not found
[Root @ localhost huangcd] # type pwd
Pwd is a shell builtin
[Root @ localhost huangcd] # type cp
Cp is aliased to 'CP-I'

Ulimit sets the display limit for running on shell. This command is usually located in the file/etc/profile, but can be moved from the current shell or user. profile file to the location required by the user. The ulimit format is as follows:
Ulimit options

Ulimit has several options:

Option description

-A: displays the current limit.

-C: restrict the size of kernel garbage

-F: restrict the size of output files created by running processes.
[Root @ localhost huangcd] # ulimit-
Core file size (blocks,-c) 0
Data seg size (kbytes,-d) unlimited
Scheduling priority (-e) 0
File size (blocks,-f) unlimited
Pending signals (-I) 11357
Max locked memory (kbytes,-l) 32
Max memory size (kbytes,-m) unlimited
Open file (-n) 1024
Pipe size (512 bytes,-p) 8
POSIX message queues (bytes,-q) 819200
Real-time priority (-r) 0
Stack size (kbytes,-s) 10240
Cpu time (seconds,-t) unlimited
Max user processes (-u) 11357
Virtual memory (kbytes,-v) unlimited
File locks (-x) unlimited
[Root @ localhost huangcd] # ulimit-c 1
[Root @ localhost huangcd] # ulimit-
Core file size (blocks,-c) 1
Data seg size (kbytes,-d) unlimited
Scheduling priority (-e) 0
File size (blocks,-f) unlimited
Pending signals (-I) 11357
Max locked memory (kbytes,-l) 32
Max memory size (kbytes,-m) unlimited
Open file (-n) 1024
Pipe size (512 bytes,-p) 8
POSIX message queues (bytes,-q) 819200
Real-time priority (-r) 0
Stack size (kbytes,-s) 10240
Cpu time (seconds,-t) unlimited
Max user processes (-u) 11357
Virtual memory (kbytes,-v) unlimited
File locks (-x) unlimited

The wait command waits until a sub-process is completed. you can specify the process ID in the wait command. If not specified, wait until all sub-processes are completed.

Wait until all sub-processes are completed:
$ Wait

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.