Sponsored Content
Full Discussion: Why its printing like this?
Top Forums Shell Programming and Scripting Why its printing like this? Post 302825349 by Shenbaga.d on Monday 24th of June 2013 07:20:03 AM
Old 06-24-2013
Why its printing like this?

Hi,
when i use the following awk i will get the output like double time printed values and the 2nd time only its giving data,
please help me to find this
for ex: awk code:
Code:
file_name=$1
file_name1=$2
ctn=$(awk 'FNR==NR{a[$2]=$4;}$2 in a{t=a[$2]-$4;print $2,(FNR==1)?"":t"@"}' ${file_name} ${file_name1})
echo $ctn > result.tsv
sed -i 's|@|\n|g' result.tsv
sed -i 's|^ ||g' result.tsv

file.tsv
Code:
10787	10026700	sb	267.00	228.88
11485	10056416	sb	22.61	0
11416	10073755	sb	29.23	0
10879	10098634	sb	58.99	0
10674	10153713	sb	99.88	0
11462	10216854	sb	44.97	0
10793	10233900	sb	0	0
11504	10251332	sb	69.98	0
10890	10295983	sb	39.97	0
10881	10335174	sb	69.96	0
11531	10339632	sb	65.00	0
11532	10339655	sb	115.00	0
11533	10339656	sb	145.00	0
10753	10339974	sb	199.98	0
10547	10543801	sb	19.97	0
10894	10598332	sb	224.54	0
10694	10629144	sb	279.00	0
11438	10629145	sb	500.00	0
10899	10669752	sb	219.00	199.00

file1.tsv
Code:
10787	10026700	sa	267.00	228.88
11485	10056416	sa	22.61	0
11416	10073755	sa	29.74	0
10879	10098634	sa	58.99	0
10674	10153713	sa	99.88	0
11462	10216854	sa	44.97	0
10793	10233900	sa	0	0
11504	10251332	sa	0	0
10890	10295983	sa	39.97	0
10881	10335174	sa	69.96	0

result.tsv
Code:
10026700 10056416 0
10073755 0
10098634 0
10153713 0
10216854 0
10233900 0
10251332 0
10295983 0
10335174 0
10339632 0
10339655 0
10339656 0
10339974 0
10543801 0
10598332 0
10629144 0
10629145 0
10669752 0
10026700 10056416 0
10073755 -0.51
10098634 0
10153713 0
10216854 0
10233900 0
10251332 69.98
10295983 0
10335174 0

---------- Post updated at 04:50 PM ---------- Previous update was at 04:46 PM ----------

it should print the 2nd col value with the result value which is 4th col. Comparison (if it find 10056416 in file1.tsv then sub the 22.61 - 22.61 print the 0 value)

Last edited by vbe; 06-24-2013 at 08:29 AM.. Reason: missing code tag
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Printing

Do all UNIX systems have the ability to print to an ASCII file? If so, is this a common thing to do, for reports or other output? Thank you for your response. (3 Replies)
Discussion started by: SYMTRAX
3 Replies

2. UNIX for Advanced & Expert Users

Printing Problems in unix ... ( Bar-cdoe - Ip Printing)

Hi guys ... i need ur help with some printing problem in unix ... first prob. : i wanna print from my NCR unix to an Win NT , Ip based printing server ( HP JetDirect ) . My issue , is it possible to print directly to an Ip address from unix ? How do i make it work to get any results ?... (3 Replies)
Discussion started by: QuickSilver
3 Replies

3. UNIX for Dummies Questions & Answers

Printing

Ok, I found this http://docs.sun.com/?q=netstandard&p=/doc/805-7229/6j6q8svb1&a=view and I am trying to follow the section labled How To Add A Network Printer Using LP Commands But I just can't get these things to print (SUN hardware). We have an NT print server or I could print directly... (1 Reply)
Discussion started by: bbrandeb49
1 Replies

4. UNIX for Dummies Questions & Answers

printing

whenever i print a file in UNIX the bottom line gets cut off i was wondering is there any way to fix this? thanks (2 Replies)
Discussion started by: hiei
2 Replies

5. UNIX for Dummies Questions & Answers

Printing

How do I configure a UNIX printer to print to a Windows PC with vt320 emulation (0 Replies)
Discussion started by: sowlix
0 Replies

6. Shell Programming and Scripting

Printing

Hey, I'm trying to print in HP laserjet 2420 by using the command: lp -olandscape (file) For some reason it does not come out as landscape but as portrait. Help please. 10x. P.S. I'm using csh (0 Replies)
Discussion started by: Kofiko
0 Replies

7. UNIX for Advanced & Expert Users

printing \n

Hi all, In a script I need to print a string: print "\n"; but i am not able to print the above mentioned string... Please help. Regards Rochit (5 Replies)
Discussion started by: rochitsharma
5 Replies

8. Windows & DOS: Issues & Discussions

Linux to Windows Printing: PDF starts printing from middle of page.

We are using Red Hat. We have a issue like this: We want to print from Linux, to a printer attached to a Windows machine. What we want to print is a PDF. It prints, but the printing starts from the middle of the page. In the report, there is no space at the top but still printing starts from the... (5 Replies)
Discussion started by: rohan69
5 Replies

9. UNIX for Dummies Questions & Answers

Sco Unix printing : jobs hangs in queue - printing via lp versus hpnpf

Hi, We have a Unix 3.2v5.0.5. I installed a printer via scoadmin, HP network printer manager with network peripheral name (hostname and ipadres are in /etc/hosts). This is the configuration file : Code: root@sco1 # cat configurationBanner: on:AlwaysContent types: simpleDevice:... (0 Replies)
Discussion started by: haezeban
0 Replies

10. UNIX for Beginners Questions & Answers

Printing, SYSPRINTER, IP printing

Dear readers, We have a printer problem with a UNIX system. The OS is Unix IRIX 6.5 We have connected a printerto the system. If we then make a test print everything goes well . (IP printing) But if we make a print from the "orrga,i"program. Then we see all the printouts stuck within the... (3 Replies)
Discussion started by: SergevdH
3 Replies
Locale::Codes::LangExt(3)				User Contributed Perl Documentation				 Locale::Codes::LangExt(3)

NAME
Locale::Codes::LangExt - standard codes for language extension identification SYNOPSIS
use Locale::Codes::LangExt; $lext = code2langext('acm'); # $lext gets 'Mesopotamian Arabic' $code = langext2code('Mesopotamian Arabic'); # $code gets 'acm' @codes = all_langext_codes(); @names = all_langext_names(); DESCRIPTION
The "Locale::Codes::LangExt" module provides access to standard codes used for identifying language extensions, such as those as defined in the IANA language registry. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default IANA language registry codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying language extensions. A code set may be specified using either a name, or a constant that is automatically exported by this module. For example, the two are equivalent: $lext = code2langext('acm','alpha'); $lext = code2langext('acm',LOCALE_LANGEXT_ALPHA); The codesets currently supported are: alpha This is the set of three-letter (lowercase) codes from the IANA language registry, such as 'acm' for Mesopotamian Arabic. This is the default code set. ROUTINES
code2langext ( CODE [,CODESET] ) langext2code ( NAME [,CODESET] ) langext_code2code ( CODE ,CODESET ,CODESET2 ) all_langext_codes ( [CODESET] ) all_langext_names ( [CODESET] ) Locale::Codes::LangExt::rename_langext ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangExt::add_langext ( CODE ,NAME [,CODESET] ) Locale::Codes::LangExt::delete_langext ( CODE [,CODESET] ) Locale::Codes::LangExt::add_langext_alias ( NAME ,NEW_NAME ) Locale::Codes::LangExt::delete_langext_alias ( NAME ) Locale::Codes::LangExt::rename_langext_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangExt::add_langext_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangExt::delete_langext_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes::API man page. SEE ALSO
Locale::Codes The Locale-Codes distribution. Locale::Codes::API The list of functions supported by this module. http://www.iana.org/assignments/language-subtag-registry The IANA language subtag registry. AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 2011-2013 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.16.3 2013-02-27 Locale::Codes::LangExt(3)
All times are GMT -4. The time now is 02:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy