Sponsored Content
Top Forums UNIX for Dummies Questions & Answers comparing 2 string variables in unix Post 302217477 by katdaniel16 on Tuesday 22nd of July 2008 11:43:06 PM
Old 07-23-2008
Error comparing 2 string variables in unix

search=Jul 22
date=Jul 22

if [ "$search" = "$date" ]
then
echo They match

>>this piece of code does not detect that search and date are equivalent strings.. what's wrong with it?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

comparing variables

I have searched and found a few threads that have dealt with this, but the examples I've tried haven't seemed to help. I am monitoring our database log for high checkpoints. I can parse out the checkpoint value which can be anywhere from zero into a 3 digit number. I set a variable to be the... (3 Replies)
Discussion started by: MizzGail
3 Replies

2. Shell Programming and Scripting

Comparing two variables

Script #!/bin/sh hardware=PC os=WindowsNET for i in `cat newservers` do x=`sudo /opt/openv/netbackup/bin/admincmd/bpplclients |grep $i |head -40 |grep $i|awk '{print $3;exit}'` if then echo "$i is already added" else echo "Need to add" fi done O/p in debug mode bash-2.05$... (3 Replies)
Discussion started by: rajip23
3 Replies

3. Shell Programming and Scripting

Comparing Variables in Perl

Hi. I have three arrays. @a=('AB','CD','EF'); @b=('AB,'DG',HK'); @c=('DD','TT','MM'); I want to compare the elements of the first two array and if they match then so some substition. I tried using the if statement using the scalar value of the array but its not giving me any output. ... (7 Replies)
Discussion started by: kamitsin
7 Replies

4. Shell Programming and Scripting

Comparing String with Number variables

I have two variables and want to perform some functions after comparison $cat file1 14.abcde a=`cut -f 1 -d "." file1 b=15 if then .... fi but i got an error message says that unary operator expected and i think its because of $a is a string and trying to compare with... (3 Replies)
Discussion started by: bonosungho
3 Replies

5. UNIX for Dummies Questions & Answers

comparing variables

im trying to compare ipaddresses. i loop through an array to see if the ip is already is in the array and if it is it should set a flag and then i wont add it to the array. but its just adding all the ipaddresses to the array if ] then ... (3 Replies)
Discussion started by: magnia
3 Replies

6. UNIX for Dummies Questions & Answers

Comparing the characters of 2 variables

hi i am writing a hangman script and am having trouble checking the correct letters against the word i need the script to compare the word against the letters guessed that are correct so once all the letters within the word have been guessed it will alow me to create a wining senario eg ... (13 Replies)
Discussion started by: lsecer
13 Replies

7. Shell Programming and Scripting

comparing variables to date as string

I have a file $ cat myfile A 02/16/2012 B 02/19/2012 C 02/20/2012 D 02/17/2012 E 02/16/2012 My simple script > cat myscript.sh mydate="02/16/2012" awk ' ($2~/$mydate/) {print $1}' < myfile but I got no output! and when I try $2~/'$mydate'/ I got: The error context is (2 Replies)
Discussion started by: Sara_84
2 Replies

8. UNIX for Dummies Questions & Answers

Comparing a String variable with a string literal in a Debian shell script

Hi All, I am trying to to compare a string variable with a string literal inside a loop but keep getting the ./testifstructure.sh: line 6: #!/bin/sh BOOK_LIST="BOOK1 BOOK2" for BOOK in ${BOOK_LIST} do if then echo '1' else echo '2' fi done Please use next... (1 Reply)
Discussion started by: daveu7
1 Replies

9. Shell Programming and Scripting

Comparing two variables

I have a script like this. Just couldn't get the comparison part work. Any thought? thanks, #!/usr/bin/ksh -x STEP=`echo $(basename $0 .ksh) | tr "" ""` log=/skip.log while read LINE do if then echo `date`: STEP $STEP skipped by user >> $log exit 0 fi done < $1 echo... (0 Replies)
Discussion started by: ghostmic
0 Replies

10. UNIX for Beginners Questions & Answers

Comparing 2 variables in UNIX

Hi, I have 2 variables as given below. How can i compare them and say its matching ? Appreciate your help VAR1=describe/read/write VAR2=read/write/describeThanks, Please use CODE tags as required by forum rules! (4 Replies)
Discussion started by: prince1987
4 Replies
DOVEADM-SEARCH-QUERY(7) 					      Dovecot						   DOVEADM-SEARCH-QUERY(7)

NAME
doveadm-search-query - Overview of search queries for doveadm mailbox commands DESCRIPTION
Several doveadm(1) commands use a search_query in order to act only on matching messages. This manual page describes all SEARCH KEYS, which can be used in a search_query. Each search_query consists at least of one SEARCH KEY. Most of the SEARCH KEYS require an argument. All SEARCH KEYS are case-insensitive. The shortest valid search_query is ALL. For example: doveadm search ALL Multiple search query expressions will be combined with the AND operator by default. To find all messages that are new and greater than 50 kilobyte, one can use: doveadm search NEW LARGER 50k OR-ed SEARCH KEYS have to be written in parenthesis, when mixing ANDs and ORs. Shells commonly require escaping for parentheses. To find messages that were saved on the "13th of April 2007" AND have the Seen and/or Flagged flag set, one can use for example: doveadm search SAVEDON 2007-04-13 ( SEEN OR FLAGGED ) It's also possible to specify the mailbox, in which should be searched. Use either the keyword mailbox and the name of the mailbox or the keyword mailbox-guid and the mailbox's globally unique identifier in the search_query. To find all messages in the mailbox with the GUID "44f68b13ce97044b837f000035ca9452" use: doveadm search mailbox-guid 44f68b13ce97044b837f000035ca9452 ALL To list all deleted messages in the "Trash" folder use: doveadm search mailbox Trash DELETED SEARCH KEYS
The following search keys from the specification of IMAP version 4 revision 1 (see: RFC 3501, section 6.4.4) are supported: ALL Matches all messages. ANSWERED Matches messages with the IMAP flag Answered set. BCC pattern Matches messages, which contain pattern in the BCC field of the message's IMAP envelope structure. BEFORE date specification Matches messages with an internal date before date specification. BODY pattern Matches messages, which contain pattern in the body part. CC pattern Matches messages, which contain pattern in the CC field of the message's IMAP envelope structure. DELETED Matches messages with the IMAP flag Deleted set. DRAFT Matches messages with the IMAP flag Draft set. FLAGGED Matches messages with the IMAP flag Flagged set. FROM pattern Matches messages, which contain pattern in the FROM field of the message's IMAP envelope structure. HEADER field pattern Matches messages, which either have the named header field, when empty pattern was given. Or messages, where the given header field's value contains the specified pattern. KEYWORD keyword Matches messages with the given IMAP keyword (e.g. $Forwarded) flag set. LARGER size Matches messages that are larger than the specified size. MAILBOX name Matches messages in the mailbox with the specified name. MAILBOX-GUID guid Matches messages in the mailbox with the specified guid. NEW Matches messages, which have the IMAP flag Recent set but not the IMAP flag Seen. NOT search key Inverse matching - matches massages, where the search doesn't match the specified search key or its value. OLD Matches messages, which do not have the IMAP flag Recent set. ON date specification Matches messages whose internal date matches the given date specification. search key OR search key Matches messages where one of the OR-ed search keys matches. Note: IMAP4rev1 uses the syntax: OR search key search key RECENT Matches messages with the IMAP flag Recent set. SEEN Matches messages with the IMAP flag Seen set. SENTBEFORE date specification Matches messages with a Date: header before date specification. SENTON date specification Matches messages with a Date: header matching the given date specification. SENTSINCE date specification Matches messages with a Date: header matching or after the given date specification. SINCE date specification Matches messages whose internal date is within or after the given date specification. SMALLER size Matches messages with a size smaller than the given size. SUBJECT pattern Matches messages, which contain pattern in the SUBJECT field of the message's IMAP envelope structure. TEXT pattern Matches messages, which contain pattern in the message body. TO pattern Matches messages, which contain pattern in the TO field of the message's IMAP envelope structure. UID sequence Matches messages with the given UID(s). A sequence may be a single UID. Can be a sequence range, written as from:to, e.g. 100:125. As comma separated list of UIDs, e.g. 11,50,4. It's also possible to combine multiple sequences, e.g. 1,3,5,7,10:20. UNANSWERED Matches messages, which do not have the IMAP flag Answered set. UNDELETED Matches messages, which do not have the IMAP flag Deleted set. UNDRAFT Matches messages, which do not have the IMAP flag Draft set. UNFLAGGED Matches messages, which do not have the IMAP flag Flagged set. UNKEYWORD keyword Matches messages, which do not have the given IMAP keyword flag set UNSEEN Matches messages, which do not have the IMAP flag Seen set. DOVEADM SEARCH KEYS Additional search keys, provided by doveadm(1). SAVEDBEFORE date specification Matches messages, which were saved before date specification. SAVEDON date specification Matches messages whose save date matches the given date specification. SAVEDSINCE date specification Matches messages with a save date matching or after the given date specification. DATE SPECIFICATION
doveadm(1) supports a few additional date specification formats. They can be used anywhere, where a date specification value is obliga- tory. day-month-year Default IMAP4rev1 date format. day, the day of month: 1-31. month, the abbreviated month name: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov or Dec. year, four digits of year, e.g. 2007. For example the "13th of April 2007" will be represented as 13-Apr-2007. interval Combination of a positive integer number and a time unit. Available time units are: weeks (abbr: w), days (abbr: d), hours (abbr: h), mins (abbr: m) and secs (abbr: s). To match messages from last week, you may specify for example: since 1w, since 1weeks or since 7days. Unix timestamp A 10 digit Unix timestamp, seconds since the 1st of January 1970, 00:00:00 UTC. For example the "13th of April 2007" will be repre- sented as 1176418800. YYYY-MM-DD Extended ISO-8601 calendar date format. For example the "13th of April 2007" will be represented as 2007-04-13. SIZE
doveadm(1) provides also an additional size representation format. The following formats can be used anywhere, where a size value is obligatory. octets The message size in octets, as specified in the IMAP4rev1 specification. size The message size in B (byte), k (kilobyte), M (megabyte), G (gigabyte) or T (terabyte). To match messages, bigger than 1 megabyte, you may specify for example: larger 1M or larger 1024k. SEE ALSO
doveadm(1), doveadm-search(1) Dovecot v2.1 2011-11-24 DOVEADM-SEARCH-QUERY(7)
All times are GMT -4. The time now is 01:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy