ALT Linux Community general discussions
 help / color / mirror / Atom feed
* [Comm] Вопрос по bash и grep
@ 2004-11-20 12:01 Jury Levykin
  2004-11-20 12:29 ` Maxim Bodyansky
  2004-11-20 12:40 ` Alex Yustasov
  0 siblings, 2 replies; 4+ messages in thread
From: Jury Levykin @ 2004-11-20 12:01 UTC (permalink / raw)
  To: community

Столкнулся со следующей проблемой:

при использовании команды grep:
cat $FILE | grep 'text1  text2'

команда выполлняется правильно, но мне нужно брать строку 
'text1  text2' из переменной:

S='text1  text2'
cat $FILE | grep $S

в этом случае получаю следующее:
grep: text2: No such file or directory


Я пробовал следующие варианты:
S=\''text1  text2'\'
cat $FILE | grep $S

S=\"'text1  text2'\"
cat $FILE | grep $S

S=\''text1  text2'\'
cat $FILE | grep ${S}

результат тотже. :(

Поиски в интернете и чтение man grep результата на дали.

Подскажите, в чем здесь проблема,
почему если паттерн задан как переменная grep режет его на части?




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

* Re: [Comm] Вопрос по bash и grep
  2004-11-20 12:01 [Comm] Вопрос по bash и grep Jury Levykin
@ 2004-11-20 12:29 ` Maxim Bodyansky
  2004-11-20 12:56   ` Jury Levykin
  2004-11-20 12:40 ` Alex Yustasov
  1 sibling, 1 reply; 4+ messages in thread
From: Maxim Bodyansky @ 2004-11-20 12:29 UTC (permalink / raw)
  To: community

Jury Levykin <altcomm@list.ru> writes:

> Столкнулся со следующей проблемой:
> 
> при использовании команды grep:
> cat $FILE | grep 'text1  text2'
> 
> команда выполлняется правильно, но мне нужно брать строку 'text1
> text2' из переменной:
> 
> S='text1  text2'
> cat $FILE | grep $S
> 
> в этом случае получаю следующее:
> grep: text2: No such file or directory

попробуйте:
cat $FILE | grep -e "$S"


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

* Re: [Comm] Вопрос по bash и grep
  2004-11-20 12:01 [Comm] Вопрос по bash и grep Jury Levykin
  2004-11-20 12:29 ` Maxim Bodyansky
@ 2004-11-20 12:40 ` Alex Yustasov
  1 sibling, 0 replies; 4+ messages in thread
From: Alex Yustasov @ 2004-11-20 12:40 UTC (permalink / raw)
  To: community

On Sat, Nov 20, 2004 at 03:01:54PM +0300, Jury Levykin wrote:
> 
> S=\''text1  text2'\'
> cat $FILE | grep ${S}
> 
> результат тотже. :(
> 
> Поиски в интернете и чтение man grep результата на дали.
> 
> Подскажите, в чем здесь проблема,
> почему если паттерн задан как переменная grep режет его на части?
S="text1  text2"
cat $FILE | grep "$S"




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

* Re: [Comm] Вопрос по bash и grep
  2004-11-20 12:29 ` Maxim Bodyansky
@ 2004-11-20 12:56   ` Jury Levykin
  0 siblings, 0 replies; 4+ messages in thread
From: Jury Levykin @ 2004-11-20 12:56 UTC (permalink / raw)
  To: community

Maxim Bodyansky пишет:

>попробуйте:
>cat $FILE | grep -e "$S"
>  
>
Помогло :)
Спасибо всем откликнувшимся!


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

end of thread, other threads:[~2004-11-20 12:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-20 12:01 [Comm] Вопрос по bash и grep Jury Levykin
2004-11-20 12:29 ` Maxim Bodyansky
2004-11-20 12:56   ` Jury Levykin
2004-11-20 12:40 ` Alex Yustasov

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