How to copy data into a single file plus title


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to copy data into a single file plus title
# 1  
Old 05-14-2007
How to copy data into a single file plus title

Hi

Can anyone help me with the task below?

Example:

The contents in fileA.txt are:
HELLO
HOW DO U DO?

The contents in fileA.txt are:
HI
I AM FINE.

how to combine the data in 2 files into one with the format below?
Case A-fileA.txt
HELLO
HOW DO U DO?

Case B-fileB.txt
HI
I AM FINE.

Thanks a lot in advance.
# 2  
Old 05-14-2007
What are the differences between input and output files ?

Jean-Pierre.
# 3  
Old 05-14-2007
hi

sorry for my unclear description of the problem.

I have two input files (fileA.txt and fileB.txt), and would like to write the contents of two input files into a new file(let says combine.txt).
In the new file, I would like to add some headers/titles(let say CaseA-fileA.txt and CaseB-fileB.txt) before every set of contents so that I know which content is belonging to which file.
# 4  
Old 05-14-2007
something like this
Code:
echo "Case A-fileA.txt" > newfile
cat fileA >> newfile
echo "Case B-fileb.txt" >> newfile
cat fileb >> newfile

# 5  
Old 05-15-2007
Hi.

You can play around with options on pr -- here's an example:
Code:
#!/bin/sh

# @(#) s1       Demonstrate pr.

for i
do
        pr -F -l24 $i
done

exit 0

Which, when run with your data produces:
Code:
% ./s1 d*
2007-05-15 08:08                      data1                       Page 1


HELLO
HOW DO U DO?

2007-05-15 08:08                      data2                       Page 1


HI
I AM FINE.

As usual, see the man page for details and other options -- man pr ... cheers, drl
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

More > 1 TB single file cant copy

good evening, hi, I have problem for copy file, size more > 1 TB, just only for single file. error said, capacity not enough, even my storage I set to 4 TB, file always reject during finish copy. but, if I copy with multiple file/separate file, total calculation file is 2 TB, always success.... (10 Replies)
Discussion started by: katumping
10 Replies

2. Shell Programming and Scripting

How to merge the multiple data files as a single file?

Hi Experts, I have created multiple scripts and send the output to new file, getting this output to my mailbox on daily basis. I would like to send the all outputs to a single file, need to merge all file outputs on a single file. For example, Created script for df -h > df.doc grep... (7 Replies)
Discussion started by: seenuvasan1985
7 Replies

3. UNIX for Advanced & Expert Users

How to extract data from single first cell and copy it notepad?

how to extract data from single first cell and copy it notepad sample source IN EXCEL DD-MM-YYYY LOANNUM LOANPARTID OUTPUT IN NOTEPAD DD-MM-YYYY I WANT ALONE DATE SHOULD BE EXTRACTED FROM EXCEL AND COPY IT IN NOTEPAD CAN ANYONE HELP REGARDING THIS USING SCRIPTS (2 Replies)
Discussion started by: gchandu
2 Replies

4. Shell Programming and Scripting

Execute sequential files and store data in single file

1)In a particualr path i have a set of inputfiles like path:/defaultmis/MonthlyLoads/INFA_EXPORT_022013/map* example: 1)map_de 2)map_cod 3)map_feg ........and so on in above path there wil be nearly 15 to 20 files starting with map and in other path i have another file input file... (4 Replies)
Discussion started by: katakamvivek
4 Replies

5. Shell Programming and Scripting

Merge the data from two servers into a single file

Hi All, Need your inputs for the below. I have 2 different servers 611 & 610, where i would be running two scripts. And would would be running one script from 611 at every 4 hours to merge the data from the 2 servers into 2 files and send a mail. so below is the code snippet for 611: ... (3 Replies)
Discussion started by: ss_ss
3 Replies

6. Shell Programming and Scripting

copy data from different file with some same column

I have file1 have below data ABCDE2012 ABCDE2012120 -099.8 -099.4 00.4 ABCDE2012 ABCDE2012124 -104.6 -103.6 01.0 ABCDE2012 ABCDE2012128 -104.4 -103.1 01.4 file2 ABCDE2012 ABCDE2012120 15.4 ABCDE2012 ABCDE2012124 18.5 ABCDE2012 ABCDE2012128 20.1 ABCDE2012 ABCDE2012122 0.5 ... (1 Reply)
Discussion started by: pareshkp
1 Replies

7. UNIX for Dummies Questions & Answers

Need to copy data from one position to another in file

Hi. I need to write a script that will allow me to copy data from one position in a line to another position while changing the first 2 bytes of the data to a constant. Here is an example of a line of data before and what it needs to look like after. there are about 200 lines in the file. ... (1 Reply)
Discussion started by: wlb_shore_user
1 Replies

8. Shell Programming and Scripting

how to copy data to to excel file

Hi, Can any one tell me how to copy data using shell script to a excel file from text file to other columns of excel file,leaving first column unaffected i.e it should not overwrite data in first column. Say my text file data is: 15-dec-2008 15-dec-2009 16-dec-2008 16-dec-2009 ... (7 Replies)
Discussion started by: tucs_123
7 Replies

9. UNIX for Dummies Questions & Answers

get the data in a file into single string

Hello everyone ! I need to get the data in a file into a string. file1 1 2 3 4 5 I need to write a script where the file1 info is stored in a string (say variable s). So the output should be 1,2,3,4,5 or (1,2,3,4,5) If i say echo $s or print $s output should be 1,2,3,4,5 or ... (7 Replies)
Discussion started by: i.scientist
7 Replies

10. UNIX for Dummies Questions & Answers

Copy single file to multiple directories

Please help - I need to copy a single file to multiple directories. Dir structure: Parent_Directoy Filename1 Child_Directory1 Child_Directory2 Child_Directory3 Child_Directory4 .... So I need to copy Filename1 to all of the... (2 Replies)
Discussion started by: kthatch
2 Replies
Login or Register to Ask a Question