05-24-2007
Got it to work
Thank you for the help mate.
Got it to work like this:
cost=30
a=$(( cost + $( cut -c23-26 5) ))
echo $a
8 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi all!
here is a sample of the file i am working on :
$ cat toto.txt
$20030613150250:Flux:ASS_IARD
20030613150250:Nombre d enregistrements Ecrits :27
20030613150250:Flux:ASS_TIER
20030613150250:Nombre d enregistrements Ecrits :27
20030613150251:Flux:ASS_PERS
20030613150251:Nombre d... (1 Reply)
Discussion started by: HowardIsHigh
1 Replies
2. UNIX for Dummies Questions & Answers
I have three computers A, B and C. To login to B and C I should use A because it has a SSH key. I don't have any other way of accessing these two computers. Now, if I need to transfer a file between B and C, I am unable to find a way that would work... because I don't know how to authenticate... (1 Reply)
Discussion started by: Legend986
1 Replies
3. Ubuntu
I have built kernel 2.6.35 on my Ubuntu system with some specific requirement. I also built some app defined module with the same kernel. I booted up the built version and I find it did not work properly as there is some gui and other modules missing problem. But the system booted up and I did... (0 Replies)
Discussion started by: sunilsukumar4u
0 Replies
4. Shell Programming and Scripting
I wrote a script to give a user 5 guesses on what is my favorite color but I it doesn't work. I've only been scripting for a couple weeks and need some help it seems simple but how do I give the user 5 guesses? (3 Replies)
Discussion started by: noob
3 Replies
5. Programming
I use a binary name (ie polo) it gets some parameter , so for debugging normally i do this :
i wrote script for watchdog my app (polo) and check every second if it's not running then start it , the problem is , if my app , remain in state of segmentation fault for a while (ie 15 ... (6 Replies)
Discussion started by: pooyair
6 Replies
6. Homework & Coursework Questions
this is a network programming code to run a rock paper scissors in a client and server.
I completed it and it was working without any error. After I added the findWinner function to the server code it starts giving me segmentation fault.
-the segmentation fault is fixed
Current problem -Also... (3 Replies)
Discussion started by: femchi
3 Replies
7. Homework & Coursework Questions
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
I have written a script for a dice game that: (1) tells user that each of the 2 die are 6 sided (Spots=6); (2)... (3 Replies)
Discussion started by: LaurenRose
3 Replies
8. Programming
Oddities with gcc, 2.95.3 for the AMIGA and 4.2.1 for MY current OSX 10.14.1...
I am creating a basic calculator for the AMIGA ADE *NIX emulator in C as it does not have one.
Below are two very condensed snippets of which I have added the results inside the each code section.
IMPORTANT!... (11 Replies)
Discussion started by: wisecracker
11 Replies
LEARN ABOUT PHP
levenshtein
LEVENSHTEIN(3) 1 LEVENSHTEIN(3)
levenshtein - Calculate Levenshtein distance between two strings
SYNOPSIS
int levenshtein (string $str1, string $str2)
DESCRIPTION
int levenshtein (string $str1, string $str2, int $cost_ins, int $cost_rep, int $cost_del)
The Levenshtein distance is defined as the minimal number of characters you have to replace, insert or delete to transform $str1 into
$str2. The complexity of the algorithm is O(m*n), where n and m are the length of $str1 and $str2 (rather good when compared to simi-
lar_text(3), which is O(max(n,m)**3), but still expensive).
In its simplest form the function will take only the two strings as parameter and will calculate just the number of insert, replace and
delete operations needed to transform $str1 into $str2.
A second variant will take three additional parameters that define the cost of insert, replace and delete operations. This is more general
and adaptive than variant one, but not as efficient.
PARAMETERS
o $str1
- One of the strings being evaluated for Levenshtein distance.
o $str2
- One of the strings being evaluated for Levenshtein distance.
o $cost_ins
- Defines the cost of insertion.
o $cost_rep
- Defines the cost of replacement.
o $cost_del
- Defines the cost of deletion.
RETURN VALUES
This function returns the Levenshtein-Distance between the two argument strings or -1, if one of the argument strings is longer than the
limit of 255 characters.
EXAMPLES
Example #1
levenshtein(3) example
<?php
// input misspelled word
$input = 'carrrot';
// array of words to check against
$words = array('apple','pineapple','banana','orange',
'radish','carrot','pea','bean','potato');
// no shortest distance found, yet
$shortest = -1;
// loop through words to find the closest
foreach ($words as $word) {
// calculate the distance between the input word,
// and the current word
$lev = levenshtein($input, $word);
// check for an exact match
if ($lev == 0) {
// closest word is this one (exact match)
$closest = $word;
$shortest = 0;
// break out of the loop; we've found an exact match
break;
}
// if this distance is less than the next found shortest
// distance, OR if a next shortest word has not yet been found
if ($lev <= $shortest || $shortest < 0) {
// set the closest match, and shortest distance
$closest = $word;
$shortest = $lev;
}
}
echo "Input word: $input
";
if ($shortest == 0) {
echo "Exact match found: $closest
";
} else {
echo "Did you mean: $closest?
";
}
?>
The above example will output:
Input word: carrrot
Did you mean: carrot?
SEE ALSO
soundex(3), similar_text(3), metaphone(3).
PHP Documentation Group LEVENSHTEIN(3)