regular exp.
Hi,
I am working on script which can ignore Case sensitivity. suppose if user enter Linux or LINUX, scripr should accept both ways. I use: grep -i "[linux]" grep -i "[LINUX]" its not working. My script is not accepting Linux. its not accepting small letters linux. can anyone help me? thanks |
Code:
grep -i "\[linux\]" filenametosearch It will happily find [linux], [LINUX], [LiNuX] etc. PAix |
Quote:
thanks anyways |
here is my code:
li=`echo $userinput | grep -i "\[linux\]"` can anyone can help this? |
why the square brackets?
in=`echo $input|grep -i linux` if [[ $? -eq 0 ]] then echo "match" fi |
I sidelined myself and assumed he was wanting a match of linux LINUX etc with square brackets - it must be getting late.
|
In the UK def late. Lunchtime here :)
|
Quote:
|
Chrism01,
Def late= > 3.30am UK local time, well after supper and too long before breakfast - not a bad time to consider sleeping. :) PAix |
Quote:
what happen if i want to check two arguments? in=`echo $input|grep -i linux` in=`echo $input|grep -i fedora` if [[ $? -eq 0 ]] then echo "match" fi its not working at all. thanks |
$? is the status of the last run cmd, so you'd have to check each grep separately.
Perhaps you could expand on why you are doing this? |
Quote:
Code:
echo $input|grep -i linux|grep -i fedora Code:
echo $input|egrep -i "linux|fedora" |
All times are GMT -5. The time now is 12:08 AM. |