Question on Paste command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Question on Paste command
# 1  
Old 12-12-2006
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 (say 2 or 3 ). i know paste lets us use one delimter so i can get one TAB but how can we get more TABS?

One way i can think of is prepare a seperate temp file which contains just TAB character in each line and we can use

paste -d"\t" FILE1 TMP_FILE FILE2

Any other way to acheive this ?

Thanks in advance
# 2  
Old 12-12-2006
Hammer & Screwdriver

The default delimiter of Paste is tab.
In order to put in more tabs, simply replace one tab by more than one tab.

U can use sed or perl to do it.
# 3  
Old 12-12-2006
Hi C2B2

I know paste default delimeter is TAB but it will only put one char as delimeter between files even though you give multiple TABS, meaning

paste -d"\t" FILE1 FILE2 will have same result as
paste -d"\t\t..\t" FILE1 FILE2

so i hope my question is clear now and i am looking for paste solution.

Last edited by mudhireddy; 12-12-2006 at 02:04 PM.. Reason: more information
# 4  
Old 12-13-2006
Lightbulb

I meant use Sed or perl to replace that Single tab by Multiple tabs.

Do let me kno if it dosnt wrk.
# 5  
Old 12-13-2006
I dont think sed will work because data in FILE can contain TABS, if we replace TABS, original data will also get replaced.

I got the answer , anyway Thanks

yes "" |head -`wc -l FILE_1 | awk '{print $1}'` | paste FILE_1 - FILE_2

This will add two tabs and if you want 3 tabs you can do

yes "" |head -`wc -l FILE_1 | awk '{print $1}'` | paste FILE_1 - - FILE_2

assumption is file_1 and file_2 of same length here
 
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. Shell Programming and Scripting

Need help with paste command using variables

How can I accomplish this? I basically want to merge two variables onto the same line. I can do it with two FILES this way: $ cat /tmp/users_in.list | awk -F "," '{print $2}' | cut -c -1 > first.initial $ awk -F "," '{print $1}' /tmp/users_in.list | awk '{print $1}' > last.name $ paste... (5 Replies)
Discussion started by: greenlightening
5 Replies

3. Shell Programming and Scripting

Copy a column and paste to other file question

Please help me. This is simple, but urgent problem for me. :( I have a two files file1 1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6 ..... file2 11 12 13 14 15 11 12 13 14 15 11 12 13 14 15 ..... 1) I hope to make a new file, file 3, that consists of 2nd... (2 Replies)
Discussion started by: exsonic
2 Replies

4. Shell Programming and Scripting

Paste command - question

Hi, Below file content is output from pasting two files. Now, i want to output another file which just contains the difference on any line For example: JAY,2,,3,5,B+,JAY,2,,3,5,B+ ANN,5,,5,1,C,ANN,5,,5,2,C Line JAY seems to have no difference. However, line ANN has difference in on... (3 Replies)
Discussion started by: jakSun8
3 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. Shell Programming and Scripting

need help with 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 (3 Replies)
Discussion started by: drew211
3 Replies

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

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

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

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