![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Grep command | nickg | UNIX for Dummies Questions & Answers | 14 | 10-06-2008 08:22 AM |
| how to exclude the GREP command from GREP | yamsin789 | UNIX for Advanced & Expert Users | 2 | 10-04-2007 11:59 PM |
| grep command help | ishmael^soyuz | Shell Programming and Scripting | 4 | 07-11-2007 06:01 AM |
| grep command | pmsuper | UNIX for Dummies Questions & Answers | 6 | 11-22-2006 04:12 AM |
| grep command | debasis.mishra | Shell Programming and Scripting | 1 | 03-27-2006 10:53 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#8
|
|||
|
|||
|
You don't really want grep.
Code:
case $input in *[!0-9]*) echo Need a number >&2; exit 1; esac |
| Forum Sponsor | ||
|
|
|
#9
|
|||
|
|||
|
grep command
that code is really helpfull
i am just wondering if i want to check to number, is it possible to combine the code example case [ $input1 -a $input2 ] in *[!1-9]*) echo not number esac |
|
#10
|
|||
|
|||
|
grepping for text
I wrote a utility menu to do this. Try some of this code:
# find file names containing text 1) echo "" echo 'which dir or .?' read dir echo 'what text to find?' read text echo " do you want to put the findings to a file?" read answer if [ "$answer" = "y" ] then echo "outputting to text_found" find $dir -exec grep -l $text {} \; > text_found; echo "findings have been output to `pwd`/text_found" echo "would you like to view? y/n" read answer if [ "$answer" = "y" ] then more text_found fi else echo "" find $dir -exec grep -l $text {} \; 2>/dev/null|more fi ;; |
|
#11
|
|||
|
|||
|
grep command
that is so helpfull, thanks for the help
|
|
#12
|
|||
|
|||
|
Quote:
[ is a separate command (believe it or not!) and is customarily only used as an argument to if and perhaps occasionally while; case simply looks at the next token and compares it. But you can do two comparisons: Code:
case $input1 in *[!1-9]*) echo not number;; esac case $input2 in *[!1-9]*) echo not number;; esac Code:
case "$input1$input2" in *[!1-9]*) echo not number;; esac The earlier example I posted lacked the double semicolons; sorry for omitting them (though some shells can apparently cope if it's in the last branch in a case structure). Last edited by era; 05-05-2008 at 11:47 PM. Reason: Missing double semicolons in earlier reply |
|||
| Google The UNIX and Linux Forums |