Combining data from file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Combining data from file
# 8  
Old 04-16-2012
On Solaris use /usr/xpg4/bin/awk rather than awk
# 9  
Old 04-16-2012
Quote:
Originally Posted by krsnadasa
Hi Itkamaraj,

Thanks , If you do not mind can you please explain me this one liner how diff parts works..
Code:
nawk '{a=$1;a=a""substr($2,length($2)-1,length($1));getline;printf("%s %s\n",a,$0)}' input.txt

Thanks
Krsna
a=$1 --> a will hold the first field
a=a""substr($2,length($2)-1,length($1)) --> append the last character of second filed with a
getline --> read the next line ( so that $0 will be having the next line )
This User Gave Thanks to itkamaraj For This Post:
# 10  
Old 04-16-2012
Combining data from file

Hi itkamaraj ,

Got it many thanks

Thanks to all.
# 11  
Old 04-16-2012
Code:
cat FILE | paste - - | sed 's/ Name//'

This User Gave Thanks to yazu For This Post:
# 12  
Old 04-16-2012
Combining data from file

Thanks Yazu,

cat FILE | paste - - | awk '{ print $1$2 "\t" $3}' giving me right output.

Thanks again for easy sol.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Combining certain columns of multiple files into one file

Hello Unix gurus, I have a large number of files (say X) each containing two columns of data and the same number of rows. I would like to combine these files to create a unique merged file containing X columns corresponding to the second column of each file (with a bonus of having the first... (3 Replies)
Discussion started by: ksennin
3 Replies

2. UNIX for Dummies Questions & Answers

Need help combining txt files w/ multiple lines into csv single cell - also need data merge

:confused:Hello -- i just joined the forums. I am a complete noob -- only about 1 week into learning how to program anything... and starting with linux. I am working in Linux terminal. I have a folder with a bunch of txt files. Each file has several lines of html code. I want to combine... (2 Replies)
Discussion started by: jetsetter
2 Replies

3. Shell Programming and Scripting

Combining chunks of data

Hi there! Need help on some issue, I have data like this: 123 456 789 012 i need it to be like this: 123789 456012 Anyone has any idea how to do this? Thanks! Regards, Ken How to use code tags (8 Replies)
Discussion started by: kennethtls
8 Replies

4. Shell Programming and Scripting

Combining 2 lines in a file into 1 line

Hi all, I have a file with lot of lines with repeating pattern. ( TABLE_NAME line followed by Total line). I would like combine these two lines into one line seperated by cama and create a new file. Is there a simple way to do this. Current Format ( just a sample 4 lines ) TABLE_NAME:... (10 Replies)
Discussion started by: MKNENI
10 Replies

5. UNIX for Dummies Questions & Answers

Help with combining the ls and 'file' commands

I have a directory of 3000 files without extensions (Solaris 5.10). I would like to iterate the file names through the 'file' command and output their mime types (most are pdf or jpg, but a very few might be psd or swf which show simply as 'data') So, I would like the output of the 'ls'... (2 Replies)
Discussion started by: pwallace
2 Replies

6. Shell Programming and Scripting

Combining header and data and send email without usage of temp file

Dear All- My requirement is as below- Header file $ cat HEADER.txt RequestId: RequestDate: Data file $ cat DATAVAL.txt 1001|2009-03-01 I need to send the combined data below as email body via mailx command ------------------ RequestId:1001 RequestDate:2009-03-01 I would like... (4 Replies)
Discussion started by: sureshg_sampat
4 Replies

7. UNIX for Dummies Questions & Answers

Combining lines of files to new file

Hi everybody. I have a number of files that i would like to combine. however not concatenating, but rather extract lines from the files. Example: File1 ------ File2 ------File3 ... line11 ---- line21 ---- line31 ... line12 ---- line22 ---- line32 ... line13 ... (3 Replies)
Discussion started by: kabbo
3 Replies

8. Shell Programming and Scripting

Compare two csv files by two colums and create third file combining data from them.

I've got two large csv text table files with different number of columns each. I have to compare them based on first two columns and create resulting file that would in case of matched first two columns include all values from first one and all values (except first two colums) from second one. I... (5 Replies)
Discussion started by: agb2008
5 Replies

9. Shell Programming and Scripting

combining 2 files with more than one match in second file

Hello, I am attempting to combine two files where the second file can have more than one match with the lookup field (node) in the first file, onto one line of the output file. Also alerting if a lookup was not found in file2 =-=-=-=-=-=-= Example of file1 node,type =-=-=-=-=-=-= bob,232... (5 Replies)
Discussion started by: johnes42
5 Replies

10. UNIX for Dummies Questions & Answers

Combining information from a comma delimited file

I have a comma delimited file which also contains commas in the text. I was wondering how I can combine one whole column of that file with another file. In essence I'm trying to do an excel vlookup in UNIX to return the information from one column in the comma delimited file(containing text commas... (1 Reply)
Discussion started by: vzismann
1 Replies
Login or Register to Ask a Question