10-28-2009
you might not need arrays at all. Why don't you take a 'first long' list and a 'short list' and find the 'matches' - do the same with the 'second long list'.
If you post samples (short list and a one long list) and describe the 'matching' algorithm, we might help to get started.
Please use
code tags when posting data samples. Also provide the desired result based on your sample input.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I want a soultion to compare two arrays in sh with an easy way.I want a solution to synchrose users between different AIX servers where no NIS is available. All users are meant to be same on all 10 servers. So the approach is to consider first server as master user repository and whatever the users... (0 Replies)
Discussion started by: rijeshpp
0 Replies
2. Shell Programming and Scripting
I want to compare "N" (around 2000+) number of huge files located in a directory A against "N" files located in a different directory using Bash scripting.
Please help me with any scripts available.
Thanks. (2 Replies)
Discussion started by: Sangtha
2 Replies
3. Shell Programming and Scripting
Hi,
I am looking for a way to compare two text files and print the matches. For example;
File1.txt
89473036
78474384
48948408
95754748
47849030
File2.txt
47849030
46730356
16734947
78474384
36340047
Output: (11 Replies)
Discussion started by: lewk
11 Replies
4. Shell Programming and Scripting
I have the following code and for some reason when I call the program using
/home/tcdata/tatsh/trunk/hstmy/bin/bash/raytrac.bash --cmod=jcdint.cmod
I get
hasArgument =
hasArgument = true
Somehow the array element is returning even though I have not chosen the option.
... (41 Replies)
Discussion started by: kristinu
41 Replies
5. Shell Programming and Scripting
I've been trying to have an array of ip addresses go through a loop one at a time. Then compare if the current element is in another array of ip addresses. I've traced my error with /bin/bash -x
+ for c in '"${ip}"'
./netk5: line 65: 50.17.231.23 23.64.146.110 23.64.159.139 107.14.36.129... (17 Replies)
Discussion started by: Azrael
17 Replies
6. Shell Programming and Scripting
Hi,
I am trying to compare two lists that are held in two variables so I believe I need to access the array elements to compare these. I am using ksh 88 and the code I have tried is below:
for file in ${origfilelist}
do
if ]]
then
print -- "File ${file}... (3 Replies)
Discussion started by: frodo61
3 Replies
7. Shell Programming and Scripting
Hi all,
I have two files, chap.txt and complex.txt.
chap.txt looks like this:
a
d
l
m
r
k
complex.txt looks like this:
a c d e l m n j
a d l p q r
c p r m
......... (7 Replies)
Discussion started by: AshwaniSharma09
7 Replies
8. Shell Programming and Scripting
This is probably rehash but I did look. :rolleyes:
I want a bash script that will take Item 1 in File1, traverse all lines in File2 and output if a match exists. Continuing the pattern recursively, Item2, File1, traverse all lines in File2 for a match, continue this pattern until all lines... (6 Replies)
Discussion started by: rcbarr2014
6 Replies
9. Shell Programming and Scripting
I have 2 arrays of values for example
A1 ={10 15 3 21}
A2 ={10 15 3 22}
I need to check which one has greater values. However:
A1 ={10 15 3 21}
A2 ={10 15 3 21 3} - this one would be greater.
A1 ={10 15 5 21} - this one greater
A2 ={10 15 3 21}
Basically, I want to compare patch... (6 Replies)
Discussion started by: Jutsimitsu
6 Replies
10. UNIX for Beginners Questions & Answers
Hello everyone,
I need help comparing 2 arrays. the first array is static; the second array is not ..
array1=( "macOS Mojave" "iTunes" )
cd /Volumes
array2=( * )
# output of array2
macOS Mojave
iTunes
Mac me
The problem occurs when I compare the arrays with the following code -
... (6 Replies)
Discussion started by: trexthurman
6 Replies
LEARN ABOUT DEBIAN
fstrcmp
fstrcmp(1) General Commands Manual fstrcmp(1)
NAME
fstrcmp - fuzzy comparison of strings
SYNOPSIS
fstrcmp [ -p ] first-string second-string
fstrcmp -w first-string second-string
fstrcmp -a first-file second-file
fstrcmp -s needle haystack...
fstrcmp --version
DESCRIPTION
The fstrcmp command is used to make fuzzy comparisons between strings. The "edit distance" between the strings is printed, with 0.0 mean-
ing the strings are utterly un-alike, and 1.0 meaning the strings are identical.
You may need to quote the string to insulate them from the shell.
OPTIONS
The fstrcmp command understands the following options:
-a
--files-as-bytes
This option is used to compare two files as arrays of bytes. See fmemcmp(3) for more information.
-p
--pair This option is used to compare two strings as arrays of bytes. This is the default. See fstrcmp(3) for more information.
-s
--select
This option is used to select the closest needle from the provided haystack alternatives. The most similar (single) choice is
printed. If none are particularly similar, nothing is printed. See fstrcmp(3) for more information. See below for example.
-V
--version
This option may be used to print the version of the fstrcmp command, and then exit.
-w
--wide-pair
This option is used to compare two multi-byte character strings. See fstrcoll(3) for more information.
EXIT STATUS
The fstrcmp command exits with status 1 on any error. The fstrcmp command only exits with status 0 if there are no errors.
EXAMPLE
The fstrcmp --select option may be used in a shell script to improve error messages.
case "$action" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "$0: action "$action" unknown" 1>&2
guess=`fstrcmp --select "$action" stop start restart`
if [ "$guess" ]
then
echo "$0: did you mean "$guess" instead?" 1>&2
fi
exit 1
;;
esac
Thus, the error message frequently suggests the correct action in the face of simple finger problems on the command line.
SEE ALSO
fstrcmp(3)
fuzzy comparison of strings
fstrcoll(3)
fuzzy comparison of two multi-byte character strings
fstrcmpi(3)
fuzzy comparison of strings, integer variation
COPYRIGHT
fstrcmp version 0.4
Copyright (C) 2009 Peter Miller
Peter Miller <pmiller@opensource.org.au>
The comparison code is derived from the fuzzy comparison functions in GNU Gettext 0.17. The GNU Gettext comparison functions were, in
turn, derived from GNU Diff 2.7.
Copyright (C) 1988-2009 Free Software Foundation
fstrcmp(1)