[Reprint] "Shell script" line-by-row processing of text files

Transfer from http://www.cnblogs.com/dwdxdy/archive/2012/07/25/2608816.htmlThe style files are often processed on a line-by-row basis, how to get each row of data in the shell, then process the row data, and finally read the next row of data, loop

Shell Programming Basics

For C in a B C D E F g;do echo $c; Done sequentially outputFor C in a B C D E F g;do tar czvf install.log. $c. tar.gz Install.log; DoneFor C in {a.. g}; do echo $c; Done the same as aboveSeq 1 10 columns of numbersFor i in {1..10}; do echo $i;

Shell Exercises Explained

Write a script that calculates all the odd and all the even numbers within 100 and displays them separately#! /bin/bashSum1=0For i in ' SEQ 1 2 100 'Dosum1=$[$sum 1+ $i]Doneecho $sum 1Sum2=0For j in ' SEQ 2 2 100 'Dosum2=$[$sum $j]DoneEcho $sum

Three: Shell operators

1:declare commandshell Default is String typeIf subtraction is required, it needs to be defined as an integral typeDECLARE command: Change the default variable type Decalre [+/-] [option] Variable name-set type properties for variables+ Cancel

Shell Script Job

(1) Write a script: If a path does not exist, it is created as a directory, otherwise it is present, and the content type is displayed#!/bin/bash#if [$#-lt 1]; Then echo "Plz Enter a path:" Exit 1fi if [-e $]; Then file $1else mkdir-p $1fi ~Test

Bash Shell Foundation II conditional judgment

if condition judgment; ThenStatmentElseStatmentFiOrif condition judgment; ThenStatmentElifStatmentFiAnti-quote: Returns the execution result of the command to the variable.Set UserIDUserID = ' Id-u user1 'command to end a script prematurely: exit:

Special characters in the shell

In addition to ordinary characters in the shell, there are many characters with special meanings and functions.1. Wildcard characters* : string of any length? : Matches any single character[]: Matches any one of these characters, for example:[ABC]

September 13, 2015 and 15th "shell, Sed&awk use (i)"-jy1506402-19+liuhui880818

Directory:First, the operation Principle of shell programSecond, Shell common skills1. Command history2. Command aliases3. Command Reference4. File name Wildcard5. Common shortcut keys6. Complement function7. Input and output redirection and piping8.

Shell Calculation Tool Source code

#!/bin/bash# defines greatest common divisor and the minimum number of conventions gcd_result= "lcm_result=" "#定义一个相加的函数function  sum ()  { result=$ (  num1+num2 )   echo -e  "\033[31m  two number of $result \033[0m"}# Define a greatest common

Tips for Shell common commands

1.cdCD-Back to last catalogCD returns the current user's home directory2.mkdirMkdir-p Creating a multilevel directoryEg:mkdir-p Test1/test2/test33.findFind-empty Finding empty DocumentsFind-user XXX View all information about user xxxFind-mtime-1

Bash Shell Summary and examples

First, homework (exercise) content:1. Describe the operation principle of shell program (can be attached with necessary graphic instructions);2, summarize all the knowledge points involved in shell programming (such as: variables, grammar, command

Shell's "test" command

Read Catalogue Numerical test File test String test The test command in the shell is used to check if a condition is true, and it can be tested in three ways, such as numeric values, files, and characters.

Some application scenarios for the shell

List the number of connections per IPawk ' /^tcp/{print} ' awk ' !/^::/{print $ {} ' Sort Uniq Sort awk ' begin{printf "%-10s%s\n", "Connum", "IP"}{printf "%-10s%s\n", $1,$2} 'Command explanation: Netstat-n refused to display aliases, can

Linux: Common shell shortcut keys

Key function Ctrl+d Keyboard input end or exit terminal Ctrl+s Tentative current program, pause and press any key to resume operation Ctrl+z Put the current program in the

Common Linux Commands Explanation (sixth day)--shell environment variables

Too lazy, these days seem to have been lazy cancer, do not want to write a blog. Later think about, knowledge, or share the good. The first to cure their own lazy cancer; second, consolidate your knowledge by the way. There are two types of

Use shell script to build LNMP environment in one click

In order to match the previous text, here first to organize a key how to deploy LNMP environment;In fact, small and medium-sized enterprises in the production environment is also very like to use such software packages, because after all, the source

Shell 99 Multiplication Table

#!/bin/bashfor I in {1..9}dofor j in ' seq 1 $i ' dom= ' echo "$i" "*" "$j" |bc ' Echo-n "$j" x "$i" = "$m" "" Doneecho "" DoneExecution Result:[Email protected] shell]#./99.sh1 x 1 = 11 x 2 = 2 2 x 2 = 41 x 3 = 3 2 x 3 = 6 3 x 3 = 91 x 4 = 4 2 x 4 =

[9-13] Shell Series 8--Arrays

This article is intended to review the definition and assignment of arrays in shell script programming, to read arrays, and to get the length of an arrayKnowledge Reserve Array : Multiple contiguous separate memory spaces, each memory

Shell concurrently executes multithreading

Encounter FTP to more than one machine problem, waiting for the last execution to execute the next, time will be longer, if you can simultaneously send files to multiple machines, you can achieve the purpose of saving time.Grammatical

Java implementation of Shell sequencing

PackageCom.edu.hpu.sort.insert.shell;Importjava.util.Arrays;ImportCom.edu.hpu.sort.Sort; Public classShellsortextendsSort {@Override Public int[] Dosort (int[] arr) { intLen =arr.length; //all step probabilities (for the first half of the

Total Pages: 541 1 .... 420 421 422 423 424 .... 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.