Sponsored Content
Top Forums Shell Programming and Scripting prints some fields from different files into a line of new file Post 302643797 by Chubler_XL on Sunday 20th of May 2012 04:49:31 PM
Old 05-20-2012
This shoudl doe what you ask. From your existing code, the requirement is more complex than what you've asked for her, so I'll explain how this works so you can apply to what you have.

Code:
awk 'BEGIN { print "lat lon depth RMS Gap SecGap MinDis MedDis MaxDis azMaxHorUnc MaxHorAnc MinHorAnc CovvXX CovvYY CovvZZ"}
    FNR<6 { if(FNR!=1) printf " "; printf "%s", $1" "$2" "$5" "$10 }
    FNR==5 { printf "\n" }' test1 test2 test3

Firstly the above code reads all three files in 1 call to awk.
BEGIN executes before the 3 files are read and END after all three.
FNR is the row number in the individual file (NR is the total rows read so far).
printf allows strings withouta <CR> to be output.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to create a CSV File by reading fields from separate files

SHELL SCRIPT Hi, I have 3 separate files within a folder. Every File contains data in a single column like File1 contains data mayank sushant dheeraj File2 contains DSA_AT MG_AT FLAT_09 File3 contains data 123123 232323 (2 Replies)
Discussion started by: mayanksargoch
2 Replies

2. Shell Programming and Scripting

Add fields in different files only if some fields between them match

Hi everybody (first time posting here) I have a file1 that looks like > 1,101,0.1,0.1 1,26,0.1,0.1 1,3,0.1,0.1 1,97,0.5,0.5 1,98,8.1,0.218919 1,99,6.2,0.248 2,101,0.1,0.1 2,24,3.1,0.147619 2,25,23.5,0.559524 2,26,34,0.723404with 762 lines.. I have another 'similar' file2 > ... (10 Replies)
Discussion started by: murpholinox
10 Replies

3. UNIX for Dummies Questions & Answers

using sed delete a line from csv file based on specific data in two separate fields

Hello, :wall: I have a 12 column csv file. I wish to delete the entire line if column 7 = hello and column 12 = goodbye. I have tried everything that I can find in all of my ref books. I know this does not work /^*,*,*,*,*,*,"hello",*,*,*,*,"goodbye"/d Any ideas? Thanks Please... (2 Replies)
Discussion started by: Chris Eagleson
2 Replies

4. Shell Programming and Scripting

Script to compare 2 files and prints difference as output sidebyside

Hi All, Am trying script to compare 2 files and print the difference found from old file to new file on line by line basis on side by side display. Basically line by line comparision and files may contain blank line as well I know we have compare/diff commands but i don't how to make... (10 Replies)
Discussion started by: Optimus81
10 Replies

5. Shell Programming and Scripting

Compare fields in two files line by line

I am new to awk scripting. I want to do a field by word (field) comparison of two files File1.txt and File2.txt. The files contain a list of | (pipe) separated field. **File 1: ------------------- aaa|bbb|ccc|eee|fff lll|mmm|nnn|ooo|ppp rrr|sss|ttt|uuu|vvv** File 2: ... (7 Replies)
Discussion started by: dhruvmohan
7 Replies

6. Shell Programming and Scripting

Comparison of fields then increment a counter reading line by line in a file

Hi, i have a scenario were i should compare a few fields from each line then increment a variable based on that. Example file 989878|8999|Y|0|Y|N|V 989878|8999|Y|0|N|N|V 989878|8999|Y|2344|Y|N|V i have 3 conditions to check and increment a variable on every line condition 1 if ( $3... (4 Replies)
Discussion started by: selvankj
4 Replies

7. Shell Programming and Scripting

Need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line...

Hello, I need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line... An example of entries in the file would be: SRVXPAPI001 ERRO JUN24 07:28:34 1775 REASON= 0000, PROCID= #E506 #1065: TPCIPPR, INDEX= 003F ... (8 Replies)
Discussion started by: Ferocci
8 Replies

8. Shell Programming and Scripting

awk prints only last line

data.txt: NEWTEXTS="frq=63,std=-0.00533584,time=Mar-21-(09:15:03)-2016,epoch=1458576903,avg=64.2059,212.698 frq=197,std=0.587585,time=Mar-21-(09:16:02)-2016,epoch=1458576962,avg=64.2059,483.756 frq=178,std=0.503514,time=Mar-21-(09:46:02)-2016,epoch=1458578762,avg=64.2059,500... (5 Replies)
Discussion started by: SkySmart
5 Replies

9. Shell Programming and Scripting

awk to print line is values between two fields in separate file

I am trying to use awk to find all the $3 values in file2 that are between $2 and $3 in file1. If a value in $3 of file2 is between the file1 fields then it is printed along with the $6 value in file1. Both file1 and file2 are tab-delimited as well as the desired output. If there is nothing to... (4 Replies)
Discussion started by: cmccabe
4 Replies

10. UNIX for Beginners Questions & Answers

Is there a UNIX command that can compare fields of files with differing number of fields?

Hi, Below are the sample files. x.txt is from an Excel file that is a list of users from Windows and y.txt is a list of database account. $ head -500 x.txt y.txt ==> x.txt <== TEST01 APP_USER_PROFILE USER03 APP_USER_PROFILE TEST02 APP_USER_EXP_PROFILE TEST04 APP_USER_PROFILE USER01 ... (3 Replies)
Discussion started by: newbie_01
3 Replies
Geo::Coordinates::ITM(3pm)				User Contributed Perl Documentation				Geo::Coordinates::ITM(3pm)

NAME
Geo::Coordinates::ITM - Convert coordinates between lat/lon and Irish Transverse Mercator VERSION
This document describes Geo::Coordinates::ITM version 0.02 SYNOPSIS
use Geo::Coordinates::ITM qw( ll_to_grid grid_to_ll ); my ( $lat, $lon ) = grid_to_ll( $east, $north ); my ( $east, $north ) = ll_to_grid( $lat, $lon ); DESCRIPTION
Convert back and forth between Irish Transverse Mercator grid and WGS84. The conversion code was stolen wholesale from <http://bit.ly/ZqpUA>. http://svn.geograph.org.uk/svn/branches/british-isles/libs/geograph /conversionslatlong.class.php Nothing is exported by default. The exportable functions are "ll_to_grid" and "grid_to_ll". INTERFACE
"ll_to_grid" Convert a latitude, longitude (WGS84) coordinate pair into an ITM easting and northing. my ( $east, $north ) = ll_to_grid( $lat, $lon ); "grid_to_ll" Convert an ITM easting, northing pair to a WGS84 latitude, longitude. my ( $lat, $lon ) = grid_to_ll( $east, $north ); BUGS
Please report any bugs or feature requests to "bug-geo-coordinates-itm@rt.cpan.org", or through the web interface at <http://rt.cpan.org>. AUTHOR
Andy Armstrong "<andy@hexten.net>" Code gratefully stolen from <http://bit.ly/ZqpUA> http://svn.geograph.org.uk/svn/branches/british-isles/libs/geograph /conversionslatlong.class.php LICENCE AND COPYRIGHT
Copyright (c) 2009, Andy Armstrong "<andy@hexten.net>". This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic. perl v5.14.2 2012-03-31 Geo::Coordinates::ITM(3pm)
All times are GMT -4. The time now is 06:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy