Hello,
was just wondering how to compare strings in unix? I mean as in C there is a function strcmp() in string.h, is there any function in unix for that? I tried using
and all such variations but didn't succeed. Any help would be appreciated. Thanks in advance
Hi,
I am starting out to program on Unix, having had experience in C and C++ in DOS. I would like to know, of these three, which is the best book for learning C programming in Unix:
Advanced Unix Programming by Marc Rochkind
Advanced Unix Programming by Warren Gay
Advanced Programming in... (6 Replies)
hi ,
i am trying to compre two strings
if ] or if ]
when the length of var1 is small (around 300-400 char ) it works fine
but when it is large (around 900-1000 chars) it fails
is there any limitations for this type of comparison ??? (3 Replies)
hi ,
i am trying to compre two strings
if ] or if ]
when the length of var1 is small (around 300-400 char ) it works fine
but when it is large (around 900-1000 chars) it fails
is there any limitations for this type of comparison ??? (1 Reply)
I want to remove a line that has empty string at second field when I use cut with delimeter , like below
$cat demo
hello, mum
hello,
#!/bin/sh
while read line
do
if
then
# remove the current line command goes here
fi
done < "demo"
i got an error message for above... (4 Replies)
I Have a script which gets the status of oracle database and if the status is READ WRITE ..it should echo "db is up " else "db is down"
Here is the code
if
then
echo "db up"
else
echo "db down"
fi
done;
The script is giving me out put "db down" even thoug the value of... (6 Replies)
Hello everybody,
I decided to take a Unix Introduction class and have never had experience with programming. Everything was fine until recently when the Prof. started shell scripting and he wants us to make a small script to add unlimited numbers from arguments and from standard input.
I... (1 Reply)
Hello everybody,
I decided to take a Unix Introduction class and have never had experience with programming. Everything was fine until recently when the Prof. started shell scripting and he wants us to make a small script to add unlimited numbers from arguments and from standard input.
I... (8 Replies)
Hi,
can someone please help me!!! urgent!
I have a strange issue here. I grep for 2 strings from a txt files and compare the string value. Though the string values are the same, they are compared as different values. Please help
Case-1
--------
Here I grep for 2 different field values... (3 Replies)
guys , i am using inotify for monitoring one directory to check core file generation , my snippet of code is follows
#!/bin/bash
DIR=$1
inotifywait -q -e create -m $DIR | while read path events name;
do
if ]; then
echo "Now I am going to do something with $name in directory $path."... (5 Replies)
I have the logic below to look up for matches within the columns between the two files with awk.
In the if statement is where the string comparison is attempted with ==
The issue seems to be with the operands, as
1. when " '${SECTOR}' " -- double quote followed by single quote -- awk matches... (1 Reply)
Discussion started by: deadyetagain
1 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)