pasting problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting pasting problem
# 1  
Old 07-09-2012
pasting problem

Hi Friends,
Please help.
I have 2 pipe delimited files; each one has different number of rows in it. I want to use "paste" to concatenate these files.
However, while doing it, due to difference in number of rows in each files resulting file is in haphazard manner.
E.g.
file 1
Code:
Reliance Info|
Golden Gate|

File_2
Code:
9820414751
9752412453
020-2456854
02154-245871
8754123567

Code:
When I use following command
paste file_1 file_2 >file_3

cat file_3
Code:
Reliance Info|9820414751
Golden Gate|9752412453
020-2456854
02154-245871
8754123567

However I want it to look like following in excel after text-to-column.
Code:
Reliance Info	9820414751
Golden Gate	9752412453
		020-2456854
		02154-245871
		8754123567


_Anu

Last edited by Franklin52; 07-11-2012 at 05:03 PM.. Reason: Please use code tags for data and code samples, thank you
# 2  
Old 07-09-2012
You can just add "|" to the end of all lines in file2 for this.
Code:
 sed 's/$/|/g' file2 > file2_delimited

Then you can use,
Code:
 paste file1 file2_delimited > file3

I hope this should solve your problem.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Hidden characters when pasting in vi/vim

Hello everyone. When I copy some configuration settings string from MS_Word to putty from my personal pc to a remote machine, it appears that I copy some hidden symbols, which at first, cannot be seen and appear as hidden. Some java programs did not start, and after investigation I found that: ... (3 Replies)
Discussion started by: dampio
3 Replies

2. Shell Programming and Scripting

Cutting a column and pasting its number

Hello Gurus, This is my first ever post here. I tried looking for similar material but came up empty handed. Apologies if this is too verbose or if I'm not using the correct formatting. I have files containing a fixed number of elements per line; separator is a single space. Each line has the... (4 Replies)
Discussion started by: stdroid
4 Replies

3. Shell Programming and Scripting

help with pasting files in filesystem

quick question.. say i have few files in D or E drive.. i want to paste them in Filesystem that is /home/vivek folder... but when i try to do that it shows some error saying "There is not enough space on the destination. Try to remove files to make space." but i think its due to authorization... (3 Replies)
Discussion started by: vivek d r
3 Replies

4. UNIX for Dummies Questions & Answers

[Q] cutting from one column and pasting to another

I have a file laid out in columns with the first two lines line being: 219 432 4567 219 432 4587 I need to create a single line command to cut the characters in the 5th column and paste them back to the first column in the same file. (Hint:Two good solutions exist, one in which you use a... (9 Replies)
Discussion started by: mcampos7
9 Replies

5. UNIX for Dummies Questions & Answers

Pasting a column into a text file

I have two text files: One is a single column of numbers and the other is a space delimited text file with multiple columns. I want to paste the single column of numbers into the second column of the latter text file. How do I go about doing that? Thanks! (1 Reply)
Discussion started by: evelibertine
1 Replies

6. Shell Programming and Scripting

data searching and pasting with in the file

Hi All, I have .csv file in which I am trying to manipulate a column date, I started with awk but i am not sure how to do the below logic in . the file has a 23 columns and in the first row if the value is Trend and in the second column the value is Analysis then the program has to... (3 Replies)
Discussion started by: shruthidwh
3 Replies

7. Shell Programming and Scripting

pasting fields from two files into one

i have two files with contents file a 1234,abcf 2345,drft 4444,befr file b tom,3 sam,5 dog,7 i want to print first column of file b and join to file a and get output as below tom,1234,abcf sam,2345,drft dog,4444,befr (2 Replies)
Discussion started by: dealerso
2 Replies

8. Shell Programming and Scripting

pasting two files while transposing one of them

hey, I have more a structural problem. I have two input files: 1.inp: 1 2 3 a b c 2 3 4 d f g and the 2.inp 6 6 6 7 7 7 8 8 8 The goal is to get as much output files (with a name 1_2_3.dat) as lines in 1.inp are like this: 6 6 6 a 7 7 7 b 8 8 8 c (5 Replies)
Discussion started by: ergy1983
5 Replies

9. UNIX for Dummies Questions & Answers

Trouble pasting multiple files together!!

Hi, I would like to paste multiple files together into one large file. I have 23 of them and I would like to link them on a common variable without writing all the file names out (like in a simple join). Each has about 28,000 columns, but only 17 rows. So the final product would be a single file... (2 Replies)
Discussion started by: etownbetty
2 Replies

10. UNIX for Dummies Questions & Answers

pasting text into an existing file

I have a text file that has over 300 lines that I need to paste identical data to. What is the easiest way to do this? For example if I have a file that has lines of text xxxxxxxx and I would like to change each line to look like this "display text(xxxxxxxx)". What would be the easiest way to do... (3 Replies)
Discussion started by: darthur
3 Replies
Login or Register to Ask a Question