Paste command issue


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Paste command issue
# 1  
Old 08-08-2008
Power Paste command issue

Problem with Paste command Smilie
Hi All,

i need small suggestion in my below script...

i have output in .txt format like below

file1.txt
01111111
02222222
03333333

file2.txt
230125
000012
000002

now i want to merge both the file in xls or csv formate

now i am using the below command to merge the files..

paste -d ',' file1.txt file2.txt

but some time i get output like below..in unix screen..

,230125
,000012
,000002

if i open the file with xl..then i could see the output like below

01111111
230125
02222222
000012
03333333
000002

can anyone suggest me to correct it..

would be great ...

Thanks
Sha
Image
# 2  
Old 08-10-2008
Windows file have <cr><lf> with line end.
Linux file only have <lf> with line end.

So paste command can recognize <lf> between the line and the other line.

Therfore you need to exchange line end char <cr><lf> to <lf> with below command before you use paste command.

Code:
sed -e 's/\r$//' -i file1.txt
sed -e 's/\r$//' -i file2.txt

# 3  
Old 08-11-2008
MySQL

Thanks a lot....

above command working fine,,..

Thanks
Sha..Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Issue with paste command

Hi, I am facing issue with paste command. It is adding spaces or tab in between. I have say 3 files with below data File_1 TH THI THIS I File_2 IS IS S IS RE S File_3 RECORD 1 CORD 2 IS RECORD 3 (3 Replies)
Discussion started by: Simanto
3 Replies

2. UNIX for Advanced & Expert Users

Paste command formatting

Hi, I was trying to concatenate some files using paste command along with some formatting but getting stuck. The problem is: cat 1.txt A cat 2.txt B C cat3.txt D E cat 4.txt G H (5 Replies)
Discussion started by: abhi1988sri
5 Replies

3. Shell Programming and Scripting

Issue with cut and paste

let i have A file and B file A has contains 4 fields as below ---------------- f1 f2 f3 f4 B file consists of 5 fields as below -------------------- f5 f6 f7 f8 f9 need to display as below output: f5 f1 f3 f8 f9 (2 Replies)
Discussion started by: ANSHUMAN1983
2 Replies

4. UNIX for Dummies Questions & Answers

paste command without spacing?

I'm trying to combine text files without a space. So if i use the paste command paste file1 file2 file3 > file4 the new file created has spacing between the contents of the once individual files. Is there some trick I can do with a delimiter that removes the spaces.. like paste -d'' or... (1 Reply)
Discussion started by: steveinthebox
1 Replies

5. Shell Programming and Scripting

Can't paste in command line.

Hello. I've made a simple script which asks the user to input a hash and then runs a command that replaces the variable $hash with what the user inserted. The ting is that when the programm asks for input I can't paste anything there..! any clues?? :wall: (8 Replies)
Discussion started by: louboulos
8 Replies

6. UNIX for Dummies Questions & Answers

Need help with using cut and paste command

I have a file which contains 3 fields separated by tabs example andrew kid baker I need to swap kid and baker using cut and paste commands how is this to be done? Thanks (1 Reply)
Discussion started by: drew211
1 Replies

7. UNIX for Dummies Questions & Answers

paste command

input1 15 150 input2 x 10 100 input3 y 20 200 z 34 44 cmd paste -d "\t" input1 input2 input3 >>output output (1 Reply)
Discussion started by: repinementer
1 Replies

8. Shell Programming and Scripting

command paste with variables

Hi. I have an interesting problem and i couldn't find out the solution. I have two variables in which there are a lot of lines finished by \n. I would like to concatenate this two variables into one in this format: var1var2 var1var2 . . . I could do this simply by command paste but it works... (32 Replies)
Discussion started by: samos
32 Replies

9. UNIX for Dummies Questions & Answers

Question on Paste command

Hello everyone, This is Rameshreddy. I like this forum and its nice to share everyone's experience here and one can learn a lot from here. Appreciate the moderators especially. Coming to my question i have 2 files and i want to paste them with specific number of tabs as delimiters... (4 Replies)
Discussion started by: mudhireddy
4 Replies

10. UNIX for Advanced & Expert Users

paste command

I wonder if any body can help me with a command i am struggling with. I have a file with around 400 lines in, in a program i have it pulls out each line at a time so that data from the line can be cross referenced with another file. If it finds a match it pulls out a ocde from the second file, this... (5 Replies)
Discussion started by: mariner
5 Replies
Login or Register to Ask a Question