1. Reading a single file
Under shell scripts, you can read files in rows in a variety of ways, as follows:
for line in `cat ${input_filename}`do echo $ Linedone while read linedo echo $linedone < ${input_filename}
The second way is to redirect the file to standard input
2. Multiple file reading methods
How to achieve simultaneous reading of multiple files? We can continue to use the file redirection function in bash to redirect the file to a specific file descriptor with the following syntax:
n<filen>filen>>filen<>file
where n represents Open the file descriptor of the file file, similar to fd in other programming languages. If n is not specified, its default behavior is as follows:
<file #same as 0<file>file #same as 1>file<> File #same as 0<>file
We can open the file to be redirected by the exec command:
exec 7<file1exec 8<file2
Then we can read the corresponding file by the read command. Content:
read data <&7 #Use conformance is to distinguish 7 is the file descriptor, not the file name read data <&8
The sample file for multiple file reads is as follows:
readfiles() { local FD1=7 local FD2=8 local file1=$1 local file2=$2 local count1=0 local count2=0 local eof1 =0 local eof2=0 local data1 local data2 # Open files. exec 7<$fil E1 exec 8<$file2 while [[ $eof1 -eq 0
Worker. Client: The originator of the request, which can be C, PHP, Perl, MySQL UDF, etc. Job: The
In terms of file system, Linux® can be regarded as the Swiss Army Knife in the operating syste
Generally speaking, after installing ubuntu, the centralized display driver has been installed. Howe
The network is often dropped. Many technicians think that the router is unstable. The ac
XXX is not in the sudoers file. This incident will be report
Understanding of several address parameters involved in uBoot and Linux kernel
Linux log server build (rsyslog+loganalyzer)
Set the script to self-starting under Linux system
Centos boot automatically starts the SSHD service command
Find files older than 10 days in Linux and delete them
Live555 can't get ip address solution under LINUX
PHP install imagick extension tutorial
The best solution for hard disk partitioning under Linux
Solve Win7 notebook can connect to wifi but there is a yellow exclamation point
What should I do if my WindowsX system desktop card is dead?
How to delete unknown accounts in Win7 32-bit system
How to add the "Open this file with Notepad" menu option under Windows system
Can't delete files without using third-party Win7
Have a dictionary of Win8 version experience follow the trend is not lax
What should I do when I update the patch with Win7 error code 0X80070643?
Win8.1 version of Here map download: support synchronization WP8.1 device
Windows7 system can not identify Real format video files how to solve