January 11, 2017, Wednesday Shell parent-child processStart/execute mode:Current shell: #!/bin/bash must start at the beginning the first line of #! Will be discovered by the kernel, is a magic number , the kernel will
Today, we found that there are too many empty lines in a file and we intend to delete them.
So I used SED and checked the command to write it like this:
Sed '/^ $/d' file1
I found that there are still a lot of blank lines in the output content,
Preface written using BASH Shell
ProgramThe for loop is often used, especially from 1 to 100. Here we record several types of loop method classes in shell from 1 to 100.
C Language
For (I = 1; I In usage
For I in {1 .. 100} doecho $ idone
SEQ
Preface I haven't written a shell script for a long time. Today I can see such a requirement in the group as follows: I also reviewed the shell script and wrote it easily.
ProgramAfter testing, I basically passed the train of thought.
First,
Preface shell script writing can be modularized or functional. For example, test1.sh can complete an independent function and test2.sh can also complete an independent function, but test1.sh is required as the premise. Therefore, in order to save
Trap allows you to capture signals in the script. The common form of this command is:
Trap name signal (s)
Among them, name is a sequence of operations taken after the captured signal. In real life, name is generally a function specifically used
We encountered the following problems during package packaging using Linux shell scripts:
Tar: removing leading '/' from Member names
Shell Content
#! /Bin/sh
Pkg_dir =$ {PWD}/release
Pkg_name1_release.tar.gz
Tar-zvcf $ {pkg_name }$ {pkg_dir}
1. Find the number of times "Linux" appears in the file sample.txt
#! /Bin/bash # How many "Linux" in linux.txt? Grep-o "Linux" linux.txt | WC-lgrep-c "Linux" linux.txt
2. Retrieve the first column (User Name) of/etc/passwd and use "the N
From: http://standalone.javaeye.com/blog/511101
1. Use the shell variable $ randomEcho $ random
2. Use Random Functions of awkAwk 'in in {srand (); print rand ()}'
3. Use the System Device File/dev/random and/dev/urandomDd If =/dev/random | OD-
This book has no answer. If you send an email to the author, he will not provide the answer. So I had to answer the question myself.
Chapter 5
5.1
Q Cai-English-1984-Jiangsu-7
Q Cai-English-1984-Jiangsu-7
Q Cai-English-1984-Jiangsu-7
Q Cai-English-19
You often need to switch to a common directory, but the path is long and hard to remember. You want to use a script to enter the directory, but it will never change .......
Cause analysis:
When the script is executed, only a sub-process is
1. run commands in the background
Cron: System scheduling process. It can be used to run jobs during off-peak hours every day, or during different periods of one week or one month.At: Command. It is used to run some special jobs at a specific time,
Several Popular Shells
Currently, popular shell types include ash, Bash, KSh, CSH, and zsh. You can use the following command to view your own shell types:# Echo $ Shell$ Shell is an environment variable that records the shell type used by the user.
I am studying Linux Shell script recently.Linux Shell scripting tutorial (LSST) v1.05r3But because it is in English, it is also a deep impression. Now, go to the topic.
1. How to Write shell script?
A. First, use any Compiler (Vi, Vim, kwrite,...)
Publicc void setalpha (INT alpha)Alpha range: 0 ~ 255
This method is supported from eclipse3.4.
/*** Sets the operator's Alpha value which must be* Between 0 (transparent) and 255 (opaque ).* * This operation requires the operating system's advanced*
1. system environment variables after the user logs on to the system:$ Home user's own directory$ Path: the directory to be searched during Command Execution$ TZ Time Zone$ Mailcheck the number of seconds to check whether a new letter exists$ PS1
Overview
Input/Output redirection is supported in the Linux Shell environment, expressed by the symbols " ".
0 indicates standard input.
1 indicates standard output
2 indicates standard error message output
0, 1, and 2 can be used to
Run the command awk-F scriptname filename.
For example, if the first script name is bigawk. SC1, the file name is datafile # The content of datafile is the same as the previous content, so I will not post it here. You can check out the content in my
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.