Sponsored Content
Top Forums Shell Programming and Scripting awk length of digit and print at most right digit Post 302575882 by sdf on Wednesday 23rd of November 2011 06:21:29 AM
Old 11-23-2011
awk length of digit and print at most right digit

Have columns with digits and strings like:

input.txt
Code:
3840 3841 3842 Dav Thun Tax
Cahn 146; Dav.
3855 3853 3861 3862 Dav Thun Tax
2780 Karl VI.,
3873 3872 3872  Dav Thun Tax
3894 3893 3897 3899 Dav Thun Tax
403; Thun 282.
3958 3959 3960  Dav Thun Tax
3972 3972 3972 3975 Dav Thun Tax
Rom. Dav. 145;
4006 4005 4007 Dav Thun Tax

output.txt
Code:
3842 Dav Thun Tax
Cahn 146; Dav.
3862 Dav Thun Tax
2780 Karl VI.,
3872  Dav Thun Tax
3899 Dav Thun Tax
403; Thun 282.
3960  Dav Thun Tax
3975 Dav Thun Tax
Rom. Dav. 145;
4007 Dav Thun Tax

Can anybody help me on the code

Last edited by pludi; 11-23-2011 at 08:02 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to print all lines that has exactly 3 occurences of digit 4 using grep?

How to print all lines that has exactly 3 occurences of digit 4 using grep? I am able to find the pattern if it is for atleast 3 occurences but with exactly 3 occurences? Can anybody help me on this. (3 Replies)
Discussion started by: sivasai83
3 Replies

2. Shell Programming and Scripting

Replace one digit by two digit using sed

Folks, Is there a simple way to replace one digit by two digit using sed. Example, mydigit1918_2006_8_8_lag1.csv should be mydigit1918_2006_08_08_lag01.csv. I tried this way, but doesn't work. echo mydigit1989_2006_8_8_lag1.csv|sed 's/]/0]/' Thank you, (5 Replies)
Discussion started by: Jae
5 Replies

3. Shell Programming and Scripting

How to convert a 2 digit to 4 digit

Hi All, How can i convert a number 24 to 0024 In the same way how can i convert 123 to 0123? All this has to be done inside a script Thanks in advance JS (6 Replies)
Discussion started by: jisha
6 Replies

4. Shell Programming and Scripting

using awk make an field as 5 digit and display

using awk convert 3 rd fileld of file as 5 digit and then display changed file. like 1 2 23445 3452 3343 3 5 6 6 ================ o/p:- 1 2 23445 3452 03343 3 5 00006 6 (1 Reply)
Discussion started by: RahulJoshi
1 Replies

5. Shell Programming and Scripting

Single digit date to double digit date.

I have a var storing date var=`date` Now the date is returned as Mon Feb 2 00:25:48 PST 2009 Is there any way to check the date field alone ("2" in above case) and if its a single digit then add a prefix 0 to it and store the result in same variable "var" My intention in above case is... (3 Replies)
Discussion started by: villain41
3 Replies

6. Shell Programming and Scripting

Awk numeric range match only one digit?

Hello, I have a text file with lines that look like this: 1974 12 27 -0.72743 -1.0169 2 1.25029 1974 12 28 -0.4958 -0.72926 2 0.881839 1974 12 29 -0.26331 -0.53426 2 0.595623 1974 12 30 7.71432E-02 -0.71887 3 0.723001 1974 12 31 0.187789 -1.07114 3 1.08748 1975 1 1 0.349933 -1.02217... (2 Replies)
Discussion started by: meridionaljet
2 Replies

7. Shell Programming and Scripting

awk Loop 4 digit fields

Can somebody help me on this script with a loop? gawk --re-interval '{if(($1 ~ /]{4}/) && ($2 ~ /]{4}/) && ($3 ~ /]{4}/)) print $0}' I would like to loop until NF and while $i does not match ($i ~ /]{4}/) anymore then print all matching $i and exit. (5 Replies)
Discussion started by: sdf
5 Replies

8. Shell Programming and Scripting

convert two digit in to single digit...

Hi Guys. My Input: ABCD 12 00 KL ABCD 12 08 DL ABCD 12 10 KK ABCD 12 04 LL ABCD 13 00 LP ABCD 13 1O LS Output: ABCD 12 0 KL ABCD 12 8 DL ABCD 12 10 KK ABCD 12 4 LL ABCD 13 0 LP (2 Replies)
Discussion started by: pareshkp
2 Replies

9. Shell Programming and Scripting

Print a number up to last significant digit after decimal point

I want to write/print a number through a shell script up to its last significant digit (LSD) after the decimal point. Say, x=10.00056000000000000 I want to print x as x=10.00056. Note that x can be any thing so I cannot know the position of the LSD always. Thanks. (16 Replies)
Discussion started by: hbar
16 Replies

10. Shell Programming and Scripting

How to print only the digit in between a line in UNIX?

Below is my content in a file. How to print only the number in between CURDEPTH( ) ?? Please help me 5724-H72 (C) Copyright IBM Corp. 1994, 2011. ALL RIGHTS RESERVED. Starting MQSC for queue manager 1 : dis ql(DUMMY.QUEUE) curdepth AMQ8409: Display Queue details. ... (1 Reply)
Discussion started by: prince1987
1 Replies
Business::Tax::VAT::Validation(3pm)			User Contributed Perl Documentation		       Business::Tax::VAT::Validation(3pm)

NAME
Business::Tax::VAT::Validation - A class for european VAT numbers validation. SYNOPSIS
use Business::Tax::VAT::Validation; my $hvatn=Business::Tax::VAT::Validation->new(); # Check number if ($hvatn->check($VAT, [$member_state])){ print "OK "; } else { print $hvatn->get_last_error; } DESCRIPTION
This class provides an easy api to check european VAT numbers' syntax, and if they has been registered by the competent authorities. It asks the EU database (VIES) for this, using its SOAP interface methods. CONSTRUCTOR
new Class constructor. $hvatn=Business::Tax::VAT::Validation->new(); If your system is located behind a proxy : $hvatn=Business::Tax::VAT::Validation->new(-proxy => ['http', 'http://example.com:8001/']); Note : See LWP::UserAgent for proxy options. PROPERTIES
member_states Returns all member states 2-digit codes as array @ms=$hvatn->member_states; regular_expressions - Returns a hash list containing one regular expression for each country If you want to test a VAT number format ouside this module, e.g. embedded as javascript in a web form. %re=$hvatn->regular_expressions; returns ( AT => 'U[0-9]{8}', ... SK => '[0-9]{10}', ); METHODS
check - Checks if a VAT number exists in the VIES database $ok=$hvatn->check($vatNumber, [$countryCode]); You may either provide the VAT number under its complete form (e.g. BE-123456789, BE123456789) or specify the VAT and MSC (vatNumber and countryCode) individually. Valid MS values are : AT, BE, BG, CY, CZ, DE, DK, EE, EL, ES, FI, FR, GB, HU, IE, IT, LU, LT, LV, MT, NL, PL, PT, RO, SE, SI, SK local_check - Checks if a VAT number format is valid This method is based on regexps only and DOES NOT ask the VIES database $ok=$hvatn->local_check($VAT, [$member_state]); informations - Returns informations related to the last validated VAT number %infos=$hvatn->informations(); get_last_error_code - Returns the last recorded error code get_last_error - Returns the last recorded error my $err = $hvatn->get_last_error_code(); my $txt = $hvatn->get_last_error(); Possible errors are : o -1 The provided VAT number is valid. o 0 Unknown MS code : Internal checkup failed (Specified Member State does not exist) o 1 Invalid VAT number format : Internal checkup failed (bad syntax) o 2 This VAT number doesn't exist in EU database : distant checkup o 3 This VAT number contains errors : distant checkup o 17 Time out connecting to the database : Temporary error when the connection to the database times out o 18 Member Sevice Unavailable: The EU database is unable to reach the requested member's database. o 19 The EU database is too busy. o 20 Connexion to the VIES database failed. o 21 The VIES interface failed to parse a stream. This error occurs unpredictabely, so you should retry your validation request. o 257 Invalid response, please contact the author of this module. : This normally only happens if this software doesn't recognize any valid pattern into the response document: this generally means that the database interface has been modified, and you'll make the author happy by submitting the returned response !!! o 500 The VIES server encountered an internal server error. Error 500 : soap:Server TIMEOUT Error 500 : soap:Server MS_UNAVAILABLE If error_code > 16, you should temporarily accept the provided number, and periodically perform new checks until response is OK or error < 17 If error_code > 256, you should temporarily accept the provided number, contact the author, and perform a new check when the software is updated. SEE ALSO
LWP::UserAgent http://ec.europa.eu/taxation_customs/vies/faqvies.do for the FAQs related to the VIES service. FEEDBACK
If you find this module useful, or have any comments, suggestions or improvements, feel free to let me know. AUTHOR
Bernard Nauwelaerts <bpgn@cpan.org> CREDITS
Many thanks to the following people, actively involved in the development of this software by submitting patches, bug reports, new members regexps, VIES interface changes,... (sorted by last intervention) : o Bart Heupers, Netherlands. o Martin H. Sluka, noris network AG, Germany. o Simon Williams, UK2 Limited, United Kingdom & BenoA~XAXt Galy, Greenacres, France & Raluca Boboia, Evozon, Romania o Dave O., POBox, U.S.A. o Kaloyan Iliev, Digital Systems, Bulgaria. o Tom Kirkpatrick, Virus Bulletin, United Kingdom. o Andy Wardley, individual, United Kingdom. o Robert Alloway, Service Centre, United Kingdom. o Torsten Mueller, Archesoft, Germany LICENSE
GPL. Enjoy! See COPYING for further information on the GPL. DISCLAIMER
See http://ec.europa.eu/taxation_customs/vies/viesdisc.do to known the limitations of the EU validation service. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. perl v5.14.2 2012-03-26 Business::Tax::VAT::Validation(3pm)
All times are GMT -4. The time now is 03:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy