05-25-2009
awk (?) help or just general script
I have two files
(___ represents blanks)
Foo1
1000 345 456
1001 876 908
1002 ___ 786
1003 643 908
1004 345 234
and Foo2
1000 345
1001 876
1002 111
1003 643
1004 345
I would like to read column 2 in foo1 and replace with column 2 (where $1 in foo1 matches $1 in foo2) in foo2 if value is blank.
So output file
1000 345 456
1001 876 908
1002 111 786
1003 643 908
1004 345 234
Thanks
Last edited by garethsays; 05-25-2009 at 02:21 PM..
8 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi, I've been racking my brains trying to remember, but, whats the command to change the default shell? I'm currently always in the Korn shell and I want to start out in the Bash shell. I'm running a variant of BSD I guess in Mac OS X 10.2.2 and Mandrake. Thanks.
ccindyderek:confused: (4 Replies)
Discussion started by: ccindyderek
4 Replies
2. Shell Programming and Scripting
Perl, Python, and PHP are these languages easy to use? Are they command line or are they part of a GUI? (2 Replies)
Discussion started by: wmosley2
2 Replies
3. UNIX for Dummies Questions & Answers
Hi all
My job is to bootup the servers (1 sun solaris 5.8, 3 sco (release 5) and 1 windows 2000), taking backup of the servers and shut down.
Apart from this, there are nearly 150 users for our oracle9i database (forms 3 and d2k as front end). As for as oracle 9i is concerned my job is to... (0 Replies)
Discussion started by: raguramtgr
0 Replies
4. Shell Programming and Scripting
Greetings all,
Unix rookie here, just diving into ksh scripting for the first time.
My question may seem confusing but please bear with me:
If I'm understanding everything I'm reading properly, it seems like the ksh language itself doesn't have a lot of string manipulation functions of... (2 Replies)
Discussion started by: DalTXColtsFan
2 Replies
5. Shell Programming and Scripting
Status quo is, within a web application, which is coded completely in php (not by me, I dont know php), I have to fill out several fields, and execute it manually by clicking the "go" button in my browser, several times a day.
Thats because:
The script itself pulls data (textfiles) from a... (3 Replies)
Discussion started by: lowmaster
3 Replies
6. UNIX for Dummies Questions & Answers
Dear Unix community over the last couple of days I have been working on learning Unix scripting on iOS using terminal on a jail-broken device...
I am having trouble with if statements and giving the user a y or n choice that do different things when entered. The following is my code so far...... (5 Replies)
Discussion started by: mbf123
5 Replies
7. UNIX for Dummies Questions & Answers
%%%%% (9 Replies)
Discussion started by: lucasvs
9 Replies
8. UNIX for Beginners Questions & Answers
There must be thousands of one-off solutions scattered around this forum. GNU Date is so handy because it's general but if they're asking they probably don't have it. We have some nice scripts but they tend to need dates formatted in a very particular way.
This is a rough approximation which... (18 Replies)
Discussion started by: Corona688
18 Replies
LEARN ABOUT DEBIAN
algorithm::checkdigits::m10_003
CheckDigits::M10_003(3pm) User Contributed Perl Documentation CheckDigits::M10_003(3pm)
NAME
CheckDigits::M10_003 - compute check digits for ISMN
SYNOPSIS
use Algorithm::CheckDigits;
$ismn = CheckDigits('ismn');
if ($ismn->is_valid('M-345-24680-5')) {
# do something
}
$cn = $ismn->complete('M-345-24680');
# $cn = 'M-345-24680-5'
$cd = $ismn->checkdigit('M-345-24680-5');
# $cd = '5'
$bn = $ismn->basenumber('M-345-24680-5');
# $bn = 'M-345-24680'
DESCRIPTION
ALGORITHM
1. The 'M' as the first number gets the value 3. Beginning left all numbers are weighted alternatively 3 and 1.
2. The sum of all products is computed.
3. The sum of step 3 ist taken modulo 10.
4. The check digit is the difference between 10 and the number from step 3 taken modulo 10.
METHODS
is_valid($number)
Returns true only if $number consists solely of numbers and the last digit is a valid check digit according to the algorithm given
above.
Returns false otherwise,
complete($number)
The check digit for $number is computed and concatenated to the end of $number.
Returns the complete number with check digit or '' if $number does not consist solely of digits and spaces.
basenumber($number)
Returns the basenumber of $number if $number has a valid check digit.
Return '' otherwise.
checkdigit($number)
Returns the checkdigit of $number if $number has a valid check digit.
Return '' otherwise.
EXPORT
None by default.
AUTHOR
Mathias Weidner, <mathias@weidner.in-bad-schmiedeberg.de>
SEE ALSO
perl, CheckDigits, www.pruefziffernberechnung.de.
perl v5.10.0 2008-05-17 CheckDigits::M10_003(3pm)