A script used shell to extract data from the database to generate a. xml file. Only 1000 pieces of data are generated in each file. So the while read line is used as the loop. A problem was found during file counter creation. During execution, the
Description:
Although the problem is not big, it is really disgusting. My goal is to process access logs.
Logs are separated by \ t for easy processing. data needs to be filtered and processed.
I don't want to filter it into a temporary file and
First, redirect method; Piping method: Cat $FILENAME | While Read lineFunction While_read_line () {Cat $FILENAME | While Read lineDoEcho $LINEDone}Note: I only call this method the pipe method, compared to everyone should be able to see it. When the
Transfer from http://openwares.net/linux/while_read_line_last_line.htmlJust used, thank you very much, stay here for backup;While reading line reads a file, if the last line of the file does not have a newline character \ n, then read reads the last
1. Introduction to ExcelAn Excel file is a workbook workbook, where you can create multiple sheet sheet in a workbook, and a worksheet that contains multiple cell cells, which are made up of column rows (row), and are listed in uppercase English
The shell itself cannot be multi-threaded, but it can simulate multithreading by starting the subprocess and putting the child processes into the background, in order to increase the efficiency of the script while not significantly increasing the
There are many ways to read one file at a row in Linux, the most common of which is the method in the following script, and the most efficient and most used method. In order to give you an intuitive feeling, we will test the execution efficiency of
the shell reads files by line There are many ways to do this, and here are three ways to write:Writing one:#!/bin/bash# Description: # while loop read Line operation # Author: Lone Boat Dot # version:1.0#创建时间: -one- Geneva:
After more than two months of hard work, this series of blog posts is coming to an end.ArticleIt can help you in your future work and hope to have the opportunity to communicate with you technically and learn from each other, at the same time,
Yesterday before work, the boss gave a batch of log database IP address, need to count the Log table message field Top 10 results, and output to an Excel file.Spot checks, there are two types of table names that end in the date of the day. Due to
VII. non-direct reference variables:
Three methods of assigning values to standard (direct) variables are provided in shell:1. assign values directly.2. Store the output of a command.3. Store the results of a certain type of computing.However, all
12 methods for linux shell to process text line by line 1. cat $ filename | while read line example: function while_read_line {cat $ filename | while read line do www.2cto.com echo "$ line ": # This line does not do anything. The return value is 0
Original article address:
There are many methods to read files using bash scripts. Please refer to the first part. I used the while loop and the pipeline command (|) (cat $ file | while read line; do... ), And increment the I value in the loop.
This article mainly introduces examples of shell programmingFirst, the logical judgment if statement 1. Judging the age?[[email protected] 9_1 ]#cat iftest.sh #!/bin/bashread -p "Please input your age:" age ## 判断用户输入的必须是数字if [[ "$age" =~ ^[0-9]
How to read a file:First step: Pass the contents of the file to the while by pipe (|) or redirect (The second step is to call read in the while and read the contents of the file one line at a time and pay the value to the variable following read.
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.