Solved

csh shell script - test the grep command has been sucessfully match pattern.

Posted on 2008-10-04
2
3,280 Views
Last Modified: 2013-12-26
I don't know how to test the variable y whether or not containing something. Please see code below.
#!/bin/csh 

set x = 123

set y = `echo $x | grep -E "[6-9]+"`

if $y has something   //my question is here... don't know how to test it

    echo Pattern found

else

    echo Pattern not found

endif

Open in new window

0
Comment
Question by:chiachia
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 250 total points
ID: 22642385
if( "$y" != '' )then
   echo Pattern found
else
    echo Pattern not found
endif
0
 

Author Closing Comment

by:chiachia
ID: 31503099
Thank you very much!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now