Collect notes about Linux Shell

1 history The history command lists used commands. the user's history command is stored in the. bash_history file in the user's home directory. 491 sync 492 logout 493 go-m3 494 logout 495 go-m3 496 go_m3 497 ll 498 ll bin/499 go-m3 Run the 495

Shell cut command usage

Similar to awk Functions Example 1 $ A = 'echo root: X: 0: 0: Root:/root:/bin/bash | cut-D: -F 1,5 'shuohailhl @ shuohailhl-PC/cygdrive/d $ echo $ aroot: Root In the preceding example, the root: X: 0: 0: Root:/root:/bin/bash command is

Basename, dirname Shell

Basename is the name left after the directory is removed.Example: shell> temp =/home/temp/1. TestShell> base = 'basename $ temp '(reverse quotation marks)Shell> echo $ BaseResult: 1. TestDirname is the DirectoryExample: shell> temp =/home/temp/1.

How to cancel redirection in a shell program

/*************************************** ******************************* Author: Samson* Date: 08/18/2012* Test Platform:* GNU Linux version 2.6.29.4* GNU bash, version 4.0.16 (1)-release (i386-redhat-linux-gnu) ************************************

Shell string Truncation

Linux ShellTruncation character variableThe first 8 bits of the signature are as follows:1. expr substr "$ A" 1 82. Echo $ A | awk '{print substr (, 1, 8 )}'3. Echo $ A | cut-c1-84. Echo $5. expr $ :'/(.//).*'6. Echo $ A | dd BS = 1 COUNT = 8 2>/dev/

How can I obtain the output result by calling shell commands in various compilation languages?

(1) Python //ArticleAs mentioned inHttp://blog.chinaunix.net/u/12325/showart_217175.htmlEither way, And popen. Output = subprocess. popen (['Ls', '-l'], stdout = subprocess. Pipe, shell = true). commun Icate () Print Output [0] Another method is

How to Learn Linux Shell

Example about Linux Shell #! /Bin/bash echo "Hello world! " echo" Hello $ LOGNAME, it's nice talking to you " echo" U present working on a machine is 'uname-N' " echo" U Present working directory is $ (PWD) " echo" Bye for now $ LOGNAME. the time

Common shell string operations

1. String Truncation (1) intercept the string before and after a specified character [Root @ gd86 applications] # Var = Hello: zkl: zyh [Root @ gd86 applications] # echo $ {var %: *} returns the first string from right to left.Hello: zkl[Root @

Shell getopt usage

Obtain UNIX options: one advantage of UNIX is that standard Unix commands have the same command line format during execution: Command-options parameters. If the shell program is executed in the preceding format, the Bourne shell provides a statement

Shell loop, judgment introduction, and instance

There are three main types of shell loops: For, while, and. There are two main types of shell Branch judgment: If and case. 1. For Loop #! /Bin/bashfor file in $ (LS/tmp/test/mytest | grep SH) // For in is the basic format of Shell, the for in root

Basic shell programming

I used shell to write it. At that time, I had a little understanding of it. Now I completely forgot it. But I still can understand it, so I won't write it. They are all simple questions assigned by teachers.   1. Select addition, subtraction,

Unix shell programming (4)

Unix shell programming (4)   Cut commandYou can extract the required data fields from the data file or command output.Command Format: Cut-cchars FileChars indicates the characters to intercept, which can be numbers.File indicates a file. If file is

[Mac usage Basics] shell tips (continuously updated)

This article summarizes some of my frequently used shell commands or some short commands. 1. view the compile time of a tool; ll $(which appname) 2. Common for Loops for i in 1 2 3 4 5; do echo "$i"; done; for((i=140;i 3. Commonly Used File

Common commands and syntaxes for grep, awk, and sed in Shell

Common grep command syntax 1. Double quotation marks and single quotation marksWhen you input a string parameter in the g r e p command, it is best to enclose it with double quotation marks. For example, "m y s t r I n g ". There are two reasons for

Learn shell-1

1. Using securitycrt in the options-> session Options dialog box, there are many options for emulation under terminal. the Linux server has different terminal simulation packages called the terminfo database, each type corresponds to a terminfo File

Shell starts another script for statistics. awk adds the current time in each row

Control script, Stat. Sh PID_NUM=$$PID_FILE=stat.pid#echo "pid : "$PID_NUMPROG_NAME=$0ACTION=$1usage() { echo "Usage: ${PROG_NAME} {start|stop|restart}" exit 1;}start(){ sh ./stat_run.sh & PID_NUM=$! echo "worker pid is " $PID_NUM

Record the shell script execution process and variable values

/*************************************** ******************************* Author: Samson* Date: 08/17/2012* Test Platform:* GNU Linux version 2.6.29.4* GNU bash, version 4.0.16 (1)-release (i386-redhat-linux-gnu) **************************************

Use of Shell functions

Linux scripts are huge and powerful. Definition: Function Name () // function can be omitted { Command } Call: directly use the function name in the script. Of course, you can also include parameters such Function Name parameters (separated by

Shell programming (2)

The most important script language in Linux is Bash. I will write this (I will only use this :)). Compared with other development languages (such as C), bash is a relatively simple language, mainly used to write some script code, some batch

Linux Shell script instance 1

1. Write a script to calculate the factorial of 10 in a loop. #! /Bin/sh factorial = 1 for a in 'seq 1 10' DO factorial = 'expr $ factorial/* $ a' done echo "10! = $ Factorial "   2. Write a script. After the script is executed, print a

Total Pages: 541 1 .... 443 444 445 446 447 .... 541 Go to: GO

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.