It is currently Sat, 09 Dec 2023 05:47:38 GMT



 
Author Message
 grep-ing a string in csh

Is there something like TCL's regexp in csh.
Basically, can i grep a string in csh.

Thanks,
Rajesh



 Tue, 31 May 2005 03:45:37 GMT   
 grep-ing a string in csh
in comp.unix.shell i read:

no.

yes, using command substitution, echo and grep.

as an aside: don't script using csh.

--
bringing you boring signatures for 17 years



 Tue, 31 May 2005 03:55:09 GMT   
 grep-ing a string in csh
those who know me have no need of my name wrote:

How could i check if a string say, "Roses are red"
contained "red" in it using command substitution, echo
and grep?

I have to search DISPLAY variable in .cshrc to figure
out if i have logged into my account from home or work,
so i have no choice but to use csh or change my login
shell itself.

Thanks,
Rajesh



 Tue, 31 May 2005 04:24:24 GMT   
 grep-ing a string in csh
in comp.unix.shell i read:

lots of ways.  and it's basic csh scripting, so i hope i'm not answering
your homework without your having learned something.  the straightforward
method, that doesn't even use command substitution since it's just a test
is:

  echo "Roses are red" | grep -q red
  if ($status == 0) then
    echo red is present
  endif

i'd suggest the later.

but, why do you need to do this?  i'm not doubting that you have some
purpose, nor trying to cast your purpose into doubt, but if we understand
what you want to do it might be that something simple(r) is possible.

--
bringing you boring signatures for 17 years



 Tue, 31 May 2005 05:11:21 GMT   
 grep-ing a string in csh
In article <3DF8F078.7B7DD...@cisco.com>,
Rajesh B Marchappanavar  <rmarc...@cisco.com> wrote:

Perhaps something like this is what you want:

if ( "$DISPLAY" =~ *.homeisp.net:* ) then
  ...
else
  ...
endif

--
Barry Margolin, bar...@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.



 Tue, 31 May 2005 05:25:48 GMT   
 grep-ing a string in csh
those who know me have no need of my name wrote:

I have a sun workstation at work and i use gvim editor at work,  when
working from home i connect to my desktop at work using VPN.
I cannot use gvim at home because gvim window doesn't get
redirected to my windows pc at home. I have to set my EDITOR env
variable based on from where i am connected. So i am checking DISPLAY
to set EDITOR to either vi or gvim.
If there is a simpler way out of this, please let me know.

I truely appreciate all the help. BTW this is no "homework" problem this is
just "work from home" problem. :-)

Thanks a lot,
Rajesh

--

Rajesh
12/12/02

---------------------------------------------------------------------------
 Words may be false and full of art, Sighs are the natural language
 of the heart.

---------------------------------------------------------------------------



 Tue, 31 May 2005 05:31:40 GMT   
 grep-ing a string in csh

Thanks a lot Barry, this exactly what i am looking for.

Thank you,
Rajesh

- Show quoted text -



 Tue, 31 May 2005 05:44:13 GMT   
 grep-ing a string in csh
in comp.unix.shell i read:

barry's pattern match (not a regular expression though) is probably what
you want.  but there are other possibilities which depend on the method you
use to connect from home, as well as your desires.  e.g., if you are using
ssh then it already provides an x11 tunnel, so it might be useful to
install a x server on your home machine.  this isn't simple in and of
itself, but the results mean that your DISPLAY will be set appropriately,
automatically, and you'll have access to all the x utilities which you are
used to using at work.

--
bringing you boring signatures for 17 years



 Tue, 31 May 2005 06:24:43 GMT   
 
   [ 8 post ] 

Similar Threads

1. grep'ing for strings with nested spaces

2. csh/tchs: odd behaviour on prog | grep -q string

3. Grep'ing entire disk

4. HELP: Grep'ing "around" matches

5. grep-ing attackalerts from portsentry

6. recursive grep'ing

7. Grep-ing for Constants (Re: Assembler Syntax...)

8. Grep'ing two phrases

9. "grep"-ing in gzipped text-files

10. Grep'ing recursively down a directory tree


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software