ALT Linux Community general discussions
 help / color / mirror / Atom feed
* [Comm] сравнение строк в bash'e
@ 2003-04-07  6:40 Аркадий Павлик
  2003-04-07  7:02 ` Yura Kalinichenko
  2003-04-07  7:30 ` Vitaly Lipatov
  0 siblings, 2 replies; 6+ messages in thread
From: Аркадий Павлик @ 2003-04-07  6:40 UTC (permalink / raw)
  To: community

Понадобилось тут пару строк в баше сравнить...
Взял евойное хау-ту, которых в инете пруд пруди, но все как один твердят одно 
и тоже. В лоб скопировал пример оттуда (11.2), ну тот где:

#!/bin/bash
        S1='string'
        S2='String'
        if [ $S1=$S2 ];
        then
                echo  "S1('$S1') не равна to S2('$S2')"
        fi
        if [ $S1=$S1 ];
        then
                echo "S1('$S1') равна to S1('$S1')"
        fi

Выполнил. Скрипт мне весело сообщил:
S1('string') не равна to S2('String')
S1('string') равна to S1('string')

Вроде всё правильно. Но вот одно "НО" меня тревожит!
В первом if используется оператор РАВЕНСТВА!!!

Попробовал заменить = на != результат монопенисуальный.
S1('string') не равна to S2('String')
S1('string') равна to S1('string')

Где я чего пропустил?
Хотя, больше инетересует вопрос, как же эти клятые строки сравнивать? :)

-- 
С наилучшими пожеланиями,
Аркадий Павлик


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-04-07 10:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-07  6:40 [Comm] сравнение строк в bash'e Аркадий Павлик
2003-04-07  7:02 ` Yura Kalinichenko
2003-04-07  9:39   ` Аркадий Павлик
2003-04-07 10:29     ` Yura Kalinichenko
2003-04-07  7:30 ` Vitaly Lipatov
2003-04-07  9:37   ` Аркадий Павлик

ALT Linux Community general discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 community community/ http://lore.altlinux.org/community \
		mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com
	public-inbox-index community

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.community


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git