Sponsored Content
Top Forums Shell Programming and Scripting Adding Leading Zero with Right Justified and Removing Duplicates Post 302299662 by crazyhpux on Friday 20th of March 2009 05:35:58 PM
Old 03-20-2009
Quote:
Originally Posted by rikxik
Code:
awk -F"," '{
        if(_[$1]==0){
                _[$1]=1
                print $0
        }
}' a > t1
join -t"," -11 -25 t1 b | nawk -F"," '$3=sprintf("%011.2f",$3);gsub(/\./,"",$3)'

would you be so kind to explain the code a bit for me. Thank you for your help.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Stripping leading spaces on right justified name

I have a name field in a file which is right justified (yep - its true). I need to strip the leading spaces from the field and write the name out left justified. Again, I think I need to use a sed or awk command but so far, my results are at best disappointing. Thank you in advance from a UNIX... (2 Replies)
Discussion started by: Marcia P
2 Replies

2. UNIX for Dummies Questions & Answers

removing leading zero

Hi, I do have a code as follows: function deHex { if ]; then deHexDate=${1:1:$2} fi } The description given for the above code is as follows: # description: removes leading zero so value will not be recognized as hex # usage: deHex <value_parameter> <value_input_length> ... (0 Replies)
Discussion started by: risshanth
0 Replies

3. Shell Programming and Scripting

Removing leading zeros from a variable

How do I remove or add leading zeroa from a variable. To make variable 10 characters long when adding zeros. (6 Replies)
Discussion started by: toshidas2000
6 Replies

4. Shell Programming and Scripting

Removing leading and trailing spaces only in PERL

Hi All, I have a file with the following contents with multiple lines 172445957| 000005911|8| 400 Peninsula Ave.#1551 | And,K |935172445957|000005911 607573888 |000098536 | 2|Ane, B |J |Ane |1868 |19861206|20090106|20071001 I want to trim the "leading and trailing spaces only" from... (2 Replies)
Discussion started by: kumar04
2 Replies

5. Shell Programming and Scripting

Removing leading spaces from the variable value.

Hi All, I am trying to replace the value of a xml tag with a new one. But, the existing value in the xml contain leading spaces and I tried to remove that with different sed commands but all in vain. For replacing the value I wrote the command in BOLD letters below: bash-3.00$... (3 Replies)
Discussion started by: khedu
3 Replies

6. Shell Programming and Scripting

sed not removing leading zeroes

I have th following file 0000000011 0000000001 0000000231 0000000001 0000000022 noow when i run the following command sed 's/^0+//g' file name I receive the same output and the leading zeroes are not removed from the file . Please let me know how to achieve... (4 Replies)
Discussion started by: asalman.qazi
4 Replies

7. Shell Programming and Scripting

Help with adding leading zeros to a filename

Hi i need help in adding leading zero to filenames e.g file name in my folder are 1_234sd.txt 23_234sd.txt the output i need is 001_234sd.txt 023_234sd.txt can i do this shell scripting please help (2 Replies)
Discussion started by: rsmpk
2 Replies

8. Red Hat

tar: Removing leading `/' from member names

Hello, when i start to take backup following error generate please share solution for this problem i am very thankful to you. $ tar -czvf orahome.tar.gz /testhome/TEST/PROD/orahome/ tar: Removing leading `/' from member names O.S 4.5 Red Hat Thanks, Umair (1 Reply)
Discussion started by: umair
1 Replies

9. Shell Programming and Scripting

Removing leading zeros for a decimal column

removing leading zeros for a decimal column in a file which has string & decimal values ,,,,,6630140,XXXXXXXXXXXXXXX, 0020.00,USA ,,,,,6630150,XXXXXXXXXXXXXXXL (xyz, 0010.00,USA ,,,,,6630150,XXXXXXXXXXXXXXX(xyz), 1300.00,USA My file contains 9 columns. Out 9 columns, 8th column contains the... (9 Replies)
Discussion started by: marpadga18
9 Replies

10. Shell Programming and Scripting

Fixed with file- removing leading zeros and adding the space

Hi All, i have a fixed width file , where each line is 3200 length. File: 1ABC 1111 2222 3333 000012341 1001 2ABC 1111 2222 3333 000012342 1002 3ABC 1111 2222 3333 000112343 1003 1DEF 5555 4444 9696 000012344 1004 2DEF 5555 2323 8686 000012345 1005 3DEF 5555 1212 7676 000012346 1006 ... (1 Reply)
Discussion started by: mechvijays
1 Replies
File::Modified(3pm)					User Contributed Perl Documentation				       File::Modified(3pm)

NAME
File::Modified - checks intelligently if files have changed SYNOPSIS
use strict; use File::Modified; my $d = File::Modified->new(files=>['Import.cfg','Export.cfg']); while(1) { my (@changes) = $d->changed; if (@changes) { print "$_ was changed " for @changes; $d->update(); }; sleep 60; }; Second example - a script that knows when any of its modules have changed : use File::Modified; my $files = File::Modified->new(files=>[values %INC, $0]); # We want to restart when any module was changed exec $0, @ARGV if $files->changed(); DESCRIPTION
The Modified module is intended as a simple method for programs to detect whether configuration files (or modules they rely on) have changed. There are currently two methods of change detection implemented, "mtime" and "MD5". The "MD5" method will fall back to use time- stamps if the "Digest::MD5" module cannot be loaded. There is another module, File::Signature, which has many similar features, so if this module doesn't do what you need, maybe File::Signa- ture does. There also is quite some overlap between the two modules, code wise. new %ARGS Creates a new instance. The %ARGS hash has two possible keys, "Method", which denotes the method used for checking as default, and "Files", which takes an array reference to the filenames to watch. add filename, method Adds a new file to watch. "method" is the method (or rather, the subclass of "File::Modified::Signature") to use to determine whether a file has changed or not. The result is either the "File::Modified::Signature" subclass or undef if an error occurred. addfile LIST Adds a list of files to watch. The method used for watching is the default method as set in the constructor. The result is a list of "File::Modified::Signature" subclasses. update Updates all signatures to the current state. All pending changes are discarded. changed Returns a list of the filenames whose files did change since the construction or the last call to "update" (whichever last occurred). Signatures The module also creates a new namespace "File::Signature", which sometime will evolve into its own module in its own file. A file signature is most likely of little interest to you; the only time you might want to access the signature directly is to store the signature in a file for persistence and easy comparision whether an index database is current with the actual data. The interface is settled, there are two methods, "as_scalar" and "from_scalar", that you use to freeze and thaw the signatures. The imple- mentation of these methods is very frugal, there are no provisions made against filenames that contain weird characters like " " or "|" (the pipe bar), both will be likely to mess up your one-line-per-file database. An interesting method could be to URL-encode all filenames, but I will visit this topic in the next release. Also, complex (that is, non-scalar) signatures are handled rather ungraceful at the moment. Currently, I'm planning to use Text::Quote as a quoting mechanism to protect against multiline filenames. Adding new methods for signatures Adding a new signature method is as simple as creating a new subclass of "File::Signature". See "File::Signature::Checksum" for a simple example. There is one point of laziness in the implementation of "File::Signature", the "check" method can only compare strings instead of arbitrary structures (yes, there ARE things that are easier in Python than in Perl). "File::Signature::Digest" is a wrapper for Gisle Aas' Digest module and allows you to use any module below the "Digest" namespace as a signature, for example "File::Signature::MD5" and "File::Signature::SHA1". TODO * Make the simple persistence solution for the signatures better using Text::Quote. * Allow complex structures for the signatures. * Document "File::Modified::Signature" or put it down into another namespace. * Extract the "File::Modified::Signature" subclasses out into their own file. * Create an easy option to watch a whole directory tree. EXPORT None by default. COPYRIGHT AND LICENSE This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Copyright (C) 2002 Max Maischein AUTHOR
Max Maischein, <corion@cpan.org> Please contact me if you find bugs or otherwise improve the module. More tests are also very welcome ! SEE ALSO
perl,Digest::MD5,Digest, File::Signature. perl v5.8.8 2008-03-21 File::Modified(3pm)
All times are GMT -4. The time now is 08:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy