Hey guys how do I compare 2 strings from the text file,
and check for duplication?
For example, I add an item call Laptop, it will record to the textfile call file.
If it detects duplicate it will say the record record exist?
A head start would be fine for me, cuz I'm kinda new to shell scripting.
I made a function something like this, I stored the extracted data in c1 but I can't compare both of the strings. Am I doing it wrong?
c1=`grep -w $title data.txt |grep -w $author|wc -l`
I wonder if this is correct..
@aLHaNz c1 variable is holding a numeric value after all
the following code fragment
in simple speaking it says extract the lines that contains the value stored in the variable $title as a word then refine this extracted lines with another filter against the value stored in the variable $author then pass the out to some sort of line counter that what it says in final $c1 will hold a numeric value if conditions of combined filters are met.
I see no logical errors in the function
Also I see no string comparison in the snippet you sent except the pattern matching logic
So how do I compare both of the input of what the user want and the data in the text file?
Lets say user enter the title and author.
If it detects the same author it will say book existed? :/
Hi I tried the following string comparison script in Ksh88
echo "Not Equal"
Though str1 and str2 are not equal the script output says Equal .
Please correct me
Thanks (2 Replies)
Hi, So I got his code below. $year is a string of 2010,2011 etc.
I guess I want to convert $year to an integer so I can do my if statement to see if the year string is greater than 2010? Or how could I do this?
Right now I get a syntax error doing this.
fi (2 Replies)
Please I have got a file called DATE.tex which consist of
I want to use nawk to print out the dates >=01-04-2009_12:00:00
I tried this
cat plnt.new |... (6 Replies)
i am facing prob in comparing two strings that have two word.
below is the code snippet.
echo "file" $file3_name "is validated successfully"
when i run this i get the error as -bash: [: too many arguments
... (1 Reply)
i have a string in a file which gets repeated number of times like below:
and so on
using awk or grep how can i comapre the string( as the second half keeps varying) and store it in a temporary variable? I am using the... (3 Replies)
While I am trying to run below code I Am getting the exception like
./abs.sh: line 102: syntax error near unexpected token `then'
./abs.sh: line 102: ` then'
The Code Snippet is:
cat $file1 | sed -e... (8 Replies)
How do i compare two strings in shell script. Below is an example but I am not getting the desired output, plz help
I am not getting the desired output if I do this. plz help (24 Replies)