How to print 1 file then when finished another file prints beside it?


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers How to print 1 file then when finished another file prints beside it?
# 8  
Old 09-12-2019
Quote:
Originally Posted by gull04
Hi,

If by;

You actually mean to output the first file to the printer and then to reposition the paper to the first line and print the second file on a line by line basis starting at the first free print position on the line then I think that you are asking for quite a lot.

I'm going to go with the earlier contributors to this thread and suggest that paste is your best option at the moment.

You don't say anything about the system, not too mention the printer. A 4Gb file given your example of 6 chars per line would run to roughly 8 Million pages, this is going to take some time to print. So repositioning all the pages in the right order and running through the printer would be quite a task not to mention somewhat time consuming.

It starts to get really complex if you want to print a file and then run the same paper through the printer a second time printing at potentially a different start position for each line.

Regards

Gull04

How much time? I'm not worried about how much time it will take. I know it will take a some time to complete. I agree that paste will be the best option for the task. I'm using xubuntu 4.12 and CentOS-6.9-i386. So is it possible to do this task and how would I set up the cmd or bash file?

Last edited by bigvito19; 09-12-2019 at 12:58 PM..
# 9  
Old 09-13-2019
Hi,

Even if you use paste to setup one single file of approximately 8Gb and given your example of the required output, I would calculate the following.

Twelve Characters per line and Sixty Six lines per page, assuming printing on A4 paper using standard spacing would give the following ;

Pages in the file = (1024x1024x1024x8)/(66*12) = 10,845,000 Pages.

If you have a printer capable of 20 Pages Per Minute then 540,000 Minutes or 9,000 hours or 376 Days.

Post the output from below and we can take it from there.

Code:
#> LINES=`wc -l ${filename} | awk '{ print $1 }'`
#>echo ${LINES} / 66 | bc

As to the how to do it, well.

Code:
[root@fbakirpomd4 ~]# cat test_01.txt
abc
def
ghi
[root@fbakirpomd4 ~]# cat test_02.txt
123
456
789
[root@fbakirpomd4 ~]#
[root@fbakirpomd4 ~]# paste test_01.txt test_02.txt > test_03.txt
[root@fbakirpomd4 ~]# cat test_03.txt
abc     123
def     456
ghi     789
[root@fbakirpomd4 ~]# paste -d "" test_01.txt test_02.txt > test_04.txt
[root@fbakirpomd4 ~]# cat test_04.txt
abc123
def456
ghi789
[root@fbakirpomd4 ~]#

Regards

Gull04

Last edited by gull04; 09-13-2019 at 04:12 AM.. Reason: Additional Information.
This User Gave Thanks to gull04 For This Post:
# 10  
Old 09-24-2019
Quote:
Originally Posted by gull04
Hi,

Even if you use paste to setup one single file of approximately 8Gb and given your example of the required output, I would calculate the following.

Twelve Characters per line and Sixty Six lines per page, assuming printing on A4 paper using standard spacing would give the following ;

Pages in the file = (1024x1024x1024x8)/(66*12) = 10,845,000 Pages.

If you have a printer capable of 20 Pages Per Minute then 540,000 Minutes or 9,000 hours or 376 Days.

Post the output from below and we can take it from there.

Code:
#> LINES=`wc -l ${filename} | awk '{ print $1 }'`
#>echo ${LINES} / 66 | bc

As to the how to do it, well.

Code:
[root@fbakirpomd4 ~]# cat test_01.txt
abc
def
ghi
[root@fbakirpomd4 ~]# cat test_02.txt
123
456
789
[root@fbakirpomd4 ~]#
[root@fbakirpomd4 ~]# paste test_01.txt test_02.txt > test_03.txt
[root@fbakirpomd4 ~]# cat test_03.txt
abc     123
def     456
ghi     789
[root@fbakirpomd4 ~]# paste -d "" test_01.txt test_02.txt > test_04.txt
[root@fbakirpomd4 ~]# cat test_04.txt
abc123
def456
ghi789
[root@fbakirpomd4 ~]#

Regards

Gull04

How would I be able to get line 123 to to match up with every line to the left ex.
abc123
def123
ghi123 and so on?
# 11  
Old 09-24-2019
Hi,

What have you tried, can you post anything?

Regards

Gull04
# 12  
Old 09-24-2019
Quote:
Originally Posted by gull04
Hi,

What have you tried, can you post anything?

Regards

Gull04
I tried everything that's been posted, paste, cat, awk.
# 13  
Old 09-25-2019
Hi,

Your requirements seem to be changing with every post that you make, can you show us some of your data.

You originally wanted to print two files with the contents side by side, now you want to print the first file in it's entireity with the first line of the second file appended to the end of each line - is this correct?

Gull04
# 14  
Old 09-26-2019
Quote:
Originally Posted by gull04
Hi,

Your requirements seem to be changing with every post that you make, can you show us some of your data.

You originally wanted to print two files with the contents side by side, now you want to print the first file in it's entireity with the first line of the second file appended to the end of each line - is this correct?

Gull04

No I been wanted to print the first file entirely and then print the second file side by side making new lines as comes down the first file. I made a few examples.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Use while loop to read file and use ${file} for both filename input into awk and as string to print

I have files named with different prefixes. From each I want to extract the first line containing a specific string, and then print that line along with the prefix. I've tried to do this with a while loop, but instead of printing the prefix I print the first line of the file twice. Files:... (3 Replies)
Discussion started by: pathunkathunk
3 Replies

2. UNIX for Dummies Questions & Answers

Reading Xml file and print the values into the text file in columnwise?

hi guys, i want help... Reding XML file and print the values into the text file using linux shell script file as per below xml file <sequence> <Filename>aldorzum.doc</Filename> <DivisionCode>US</DivisionCode> <ContentType>Template</ContentType> <ProductCode>VIMZIM</ProductCode> </sequence>... (4 Replies)
Discussion started by: sravanreddy
4 Replies

3. 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

4. Shell Programming and Scripting

Search row by row from one file to another file if match is found print few colums of file 2

this is the requirement list.txt table1 table2 table3 testfile.txt name#place#data#select * from table1 name2#place2#data2#select * from table 10 innerjoin table3 name2#place2#data2#select * from table 10 output name place table1 name2 place table3 i tried using awk (7 Replies)
Discussion started by: vamsekumar
7 Replies

5. Shell Programming and Scripting

Script which telnets to a device, runs commands and prints output to a file

I am connecting to a device using telnet, I want my script to perform certain commands : ie- show device , show inventory..etc and write the output it sees from the terminal to a file. this is what I have got : #!/usr/bin/expect -- set running 1 spawn telnet <ip address> expect ... (1 Reply)
Discussion started by: samantha123
1 Replies

6. Shell Programming and Scripting

prints some fields from different files into a line of new file

i have 3 files as below: i want to print 1st,2nd,5th and 10th filed of 1st to 5th lines from each files into a line of an output file, so the result would be: : {line1}(field 1 of line 1 from file 1)(field 2 of line 1 from file 1)(field 5 of line 1 from file 1)(field 10 of line 1 from file... (1 Reply)
Discussion started by: saeed.soltani
1 Replies

7. Shell Programming and Scripting

check if file finished to copy

Hi all, I have a script that is monitoring a hot folder. This script works fine with one exception when the script is executed while a file is being copied to the hot folder. What is the easiest method to check if the copy file is completed? I'd like to get the solution in bash :) (8 Replies)
Discussion started by: gigagigosu
8 Replies

8. Shell Programming and Scripting

Need help with a file that prints letters from a file according to another file!

So basically what I want to do is pull out DNA sequences for a particular gene name. I have 2 files (FILE1 and FILE2) and I want an output into a separate file (FILE3). FILE1 and 2 are MASSIVE so I am only posting examples from each file. So FILE1 looks like this (tab deliminted, 4... (3 Replies)
Discussion started by: kylle345
3 Replies

9. Shell Programming and Scripting

Need shell script to read two file at same time and print out in single file

Need shell script to read two file at same time and print output in single file Example I have two files 1) file1.txt 2) file2.txt File1.txt contains Aaa Bbb Ccc Ddd Eee Fff File2.txt contains Zzz Yyy Xxx (10 Replies)
Discussion started by: sreedhargouda
10 Replies

10. UNIX for Advanced & Expert Users

How can I tell when an SFTP has finished copying a file?

If I download a file via SFTP how can I tell when the process is completed? Is there a process that I can monitor? Thanks (3 Replies)
Discussion started by: goodmis
3 Replies
Login or Register to Ask a Question