Help with data data Merge


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help with data data Merge
# 1  
Old 04-22-2015
Help with data Merge

I have a input like this

Code:
 
3
5
10
34
67

I need output like this

Code:
3-5
5-10
10-34
34-67
67

Can you please help me

Last edited by saravana.sarak; 04-22-2015 at 07:35 AM..
# 2  
Old 04-22-2015
Any attempts from your side?

---------- Post updated at 12:38 ---------- Previous update was at 12:36 ----------

Anyhow, try
Code:
awk 'NR>1{if (last) print last "-" $1; last = $1}END{print last}' file
3-5
5-10
10-34
34-67
67

This User Gave Thanks to RudiC For This Post:
# 3  
Old 04-22-2015
Quote:
Originally Posted by RudiC
Any attempts from your side?
I tried this. Dint help

Code:
 
 awk 'NR%2{printf $0" ";next;}1' filename

---------- Post updated at 05:42 AM ---------- Previous update was at 05:38 AM ----------

Quote:
Originally Posted by RudiC
Any attempts from your side?

---------- Post updated at 12:38 ---------- Previous update was at 12:36 ----------

Anyhow, try
Code:
awk 'NR>1{if (last) print last "-" $1; last = $1}END{print last}' file
3-5
5-10
10-34
34-67
67

Thanks..it is working
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Merge data in lines from same file

Need help figuring out how to merge data from a file. I have a large txt file with some data that needs to be merged from separate lines into one line. Doug.G|3/12/2011|817-555-5555|Portland Doug.G|3/12/2011|817-555-5522|Portland Steve.F|1/11/2007|817-555-5111|Portland... (5 Replies)
Discussion started by: cdubu2
5 Replies

2. Shell Programming and Scripting

Help with merge data with a reference sequence

I have two input file.: File 1 is a large reference sequence (A large Fasta sequence); File 1 (is a file which first line is the header description and line other ">" is its corresponding word and counting from 1 till end of file); >Data_1 ASWDADAQTWQQGSAAAAASDAFAFA . . File 2 is... (31 Replies)
Discussion started by: cpp_beginner
31 Replies

3. Shell Programming and Scripting

Help with merge data at same column but different row inquiry

Hi, Anyone did experience to merge data at same column but different row previously by using awk, sed, perl, etc? Input File: SSO12256 SSO0001 thiD-1 rbsK-1 SSO0006 SSO0007 SSO0008 SSO0009 SSO0010 SSO0011 Desired Output File: (5 Replies)
Discussion started by: perl_beginner
5 Replies

4. Shell Programming and Scripting

Merge and Sort tabular data from different text files

I have 42 text files; each containing up to 34 lines with following structure; file1 H-01 23 H-03 5 H-05 9 H-02 14 . . file2 H-01 17 H-02 43 H-04 7 H-05 8 H-03 7 . . file3 (6 Replies)
Discussion started by: Syeda Sumayya
6 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

AWK to match and merge data from 2 files into 1.

Hello, hopefully this is an easy on for the AWK guru's out there. I'm having some trouble figuring out how to match+merge data in 2 files into 1 single report. I've got my 2 files filtered and delimited, just need to MATCH $3 in file1 to $1 in file2, then put $0 from File1 and $2+$3 from File2... (6 Replies)
Discussion started by: right_coaster
6 Replies

7. UNIX for Dummies Questions & Answers

Merge rows in bid data file

Dear all, Please help me ,,,, if I have input file like this A_AA960715 leucine-rich repeat-containing protein GO:0006952 defense response P A_AA960715 leucine-rich repeat-containing protein GO:0008152 metabolic process P A_AA960715 leucine-rich... (5 Replies)
Discussion started by: AAWT
5 Replies

8. Shell Programming and Scripting

Help with merge data based on similarity

Input_file data1 USA 100 ASE data3 UK 20 GWQR data4 Brazil 40 QWE data2 Scotland 60 THWE data5 USA 40 QWERR Reference_file USA 12312 34532 1324 Brazil 23321 231 3421 Scotland 342 34235 UK 231 141 England... (1 Reply)
Discussion started by: patrick87
1 Replies

9. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

10. Shell Programming and Scripting

Merge 70 files into one data matrix

Hi, I have a list of 70 files in a directory and I need to merge the content of each file into one big matrix file (71 columns x 3060 rows). Each file has the following format only two columns per file: unique identifier1 randomtext1 randomtext1 a 5 b 3 c 6 d 3 e 2... (11 Replies)
Discussion started by: labrazil
11 Replies
Login or Register to Ask a Question