Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Read 2 file line by line @ same time Post 303034455 by MadeInGermany on Friday 26th of April 2019 08:33:20 AM
Old 04-26-2019
For a simple concatenation of the lines, consider paste
Code:
paste file1 file2

More flexible is the shell
Code:
while read L1 <&3 && read L2 <&4
do
  echo "$L1 #### $L2"
done 3< file1 4< file2

These 5 Users Gave Thanks to MadeInGermany For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to read/process a .gz file, one line at a time?

Hello I'm stuck trying to solve this KSH issue and I'm hoping someone out there can offer some suggestions. I want to read lots of large .gz files one line at a time in order to compare its Error entries with a list of known errors. I can't simply do "foreach ERROR do gzcat *.gz |grep... (2 Replies)
Discussion started by: dayscripter
2 Replies

2. Shell Programming and Scripting

shell script to read a line in gps receiver log file and append that line to new file

Hi, I have gps receiver log..its giving readings .like below Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. GPSD,R=1 $GPGSV,3,1,11,08,16,328,40,11,36,127,00,28,33,283,39,20,11,165,00*71... (3 Replies)
Discussion started by: gudivada213
3 Replies

3. UNIX for Advanced & Expert Users

how do you parse 1 line at a time of file1 ie. line(n) each line into new file

File 1 <html>ta da....unique file name I want to give file=>343...</html> <html>da ta 234 </html> <html>pa da 542 </html> and so on... File 2 343 234 542 and so on, each line in File 1 one also corresponds with each line in File 2 I have tried several grep, sed, while .. read, do,... (4 Replies)
Discussion started by: web_developer
4 Replies

4. Shell Programming and Scripting

bash: read file line by line (lines have '\0') - not full line has read???

I am using the while-loop to read a file. The file has lines with null-terminated strings (words, actually.) What I have by that reading - just a first word up to '\0'! I need to have whole string up to 'new line' - (LF, 10#10, 16#A) What I am doing wrong? #make file 'grb' with... (6 Replies)
Discussion started by: alex_5161
6 Replies

5. Shell Programming and Scripting

Read file line by line and process the line to generate another file

Hi, i have file which contains data as below(Only sample shown, it may contain more data similar to the one shown here) i need to read this file line by line and generate an output file like the one below i.e based on N value the number of MSISDNs will vary, if N=1 then the following... (14 Replies)
Discussion started by: aemunathan
14 Replies

6. Shell Programming and Scripting

Shell script to read a text file line by line & process it...

Hi , I am trying to write an shell, which reads a text file (from a location) having a list of numbers of strictly 5 digits only ex: 33144 Now my script will check : 1) that each entry is only 5 digits & numeric only, no alphabets, & its not empty. 2)then it executes a shell script called... (8 Replies)
Discussion started by: new_to_shell
8 Replies

7. Shell Programming and Scripting

how to read the contents of two files line by line and compare the line by line?

Hi All, I'm trying to figure out which are the trusted-ips and which are not using a script file.. I have a file named 'ip-list.txt' which contains some ip addresses and another file named 'trusted-ip-list.txt' which also contains some ip addresses. I want to read a line from... (4 Replies)
Discussion started by: mjavalkar
4 Replies

8. Shell Programming and Scripting

Need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line...

Hello, I need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line... An example of entries in the file would be: SRVXPAPI001 ERRO JUN24 07:28:34 1775 REASON= 0000, PROCID= #E506 #1065: TPCIPPR, INDEX= 003F ... (8 Replies)
Discussion started by: Ferocci
8 Replies

9. Shell Programming and Scripting

Bash script to read a file from particular line till required line and process

Hi All, Am trying to write wrapper shell/bash script on a utility tool for which i need to pass 2 files as arugment to execute utility tool. Wraper script am trying is to do with above metion 2 files. utility tool accepts : a. userinfo file : which contains username b. item file : which... (2 Replies)
Discussion started by: Optimus81
2 Replies

10. Shell Programming and Scripting

How to read file line by line and compare subset of 1st line with 2nd?

Hi all, I have a log file say Test.log that gets updated continuously and it has data in pipe separated format. A sample log file would look like: <date1>|<data1>|<url1>|<result1> <date2>|<data2>|<url2>|<result2> <date3>|<data3>|<url3>|<result3> <date4>|<data4>|<url4>|<result4> What I... (3 Replies)
Discussion started by: pat_pramod
3 Replies
paste(1)						      General Commands Manual							  paste(1)

NAME
paste - merge same lines of several files or subsequent lines of one file SYNOPSIS
file1 file2 ... list file1 file2 ... list] file1 file2 ... DESCRIPTION
In the first two forms, concatenates corresponding lines of the given input files file1, file2, etc. It treats each file as a column or columns in a table and pastes them together horizontally (parallel merging). In other words, it is the horizontal counterpart of cat(1) which concatenates vertically; i.e., one file after the other. In the option form above, replaces the function of an older command with the same name by combining subsequent lines of the input file (serial merging). In all cases, lines are glued together with the tab char- acter, or with characters from an optionally specified list. Output is to standard output, so can be used as the start of a pipe, or as a filter if is used instead of a file name. recognizes the following options and command-line arguments: Without this option, the new-line characters of all but the last file (or last line in case of the option) are replaced by a tab character. This option allows replac- ing the tab character by one or more alternate characters (see below). list One or more characters immediately following replace the default tab as the line concatenation character. The list is used circularly; i.e., when exhausted, it is reused. In parallel merging (that is, no option), the lines from the last file are always terminated with a new-line character, not from the list. The list can contain the special escape sequences: (new-line), (tab), (backslash), and (empty string, not a null character). Quoting may be necessary if charac- ters have special meaning to the shell. (For example, to get one backslash, use ). Merge subsequent lines rather than one from each input file. Use tab for concatenation, unless a list is specified with the option. Regardless of the list, the very last character of the file is forced to be a new-line. Can be used in place of any file name to read a line from the standard input (there is no prompting). EXTERNAL INFLUENCES
Environment Variables determines the locale for the interpretation of text as single- and/or multi-byte characters. determines the language in which messages are displayed. If or is not specified in the environment or is set to the empty string, the value of is used as a default for each unspecified or empty variable. If is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of If any internationalization variable contains an invalid setting, behaves as if all internationalization variables are set to "C". See environ(5). International Code Set Support Single- and multi-byte character code sets are supported. RETURN VALUE
These commands return the following values upon completion: Completed successfully. An error occurred. EXAMPLES
List directory in one column: List directory in four columns Combine pairs of lines into lines Notes works similarly, but creates extra blanks, tabs and new-lines for a nice page layout. DIAGNOSTICS
Except for the option, no more than - 3 input files can be specified (see limits(5)). AUTHOR
was developed by OSF and HP. SEE ALSO
cut(1), grep(1), pr(1). STANDARDS CONFORMANCE
paste(1)
All times are GMT -4. The time now is 02:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy