[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: The string of characters in the special character by grep as a comma
From: |
Bob Proulx |
Subject: |
Re: The string of characters in the special character by grep as a command |
Date: |
Sat, 21 Aug 2010 12:46:30 -0600 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
address@hidden wrote:
> Now, I have four files in my directory:alarm.log
> ,alarm.log.20100802125915,alarm.log.wf and control.log; I will extract
> information from alarm.log.wf, orders for grep - E "FATAL|WARNING" |tail -n
> 1, at the command line -- I got the correct output WARNING: 08-04 20:41:11:
> alarm * 1126189408 close log_r.1126189408.wf.
Your message was very difficult to read. I cannot quite understand
it. I will try. I think you wanted to say:
$ grep -E "FATAL|WARNING" alarm.log.wf | tail -n1
WARNING: 08-04 20:41:11: alarm * 1126189408 close log_r.1126189408.wf
Okay.
> But use script: ss =`grep -E "FATAL|WARNING" alarm.log.wf|tail - n 1`, echo
> $ss, output is WARNING: 08-04 20:41:11: alarm alarm.log
> alarm.log.20100802125915 alarm.log.wf control.log close
> log_r.1126189408.wf.It took "*" in the string as a special characters .I
> think this is a bug.
There is a space problem in your email making this very difficult to
read. But I will guess you wanted to say:
ss=`grep -E "FATAL|WARNING" alarm.log.wf | tail -n1`
I think that is what you meant to say.
> It took "*" in the string as a special characters .I think this is a
> bug.
Not in the assignment. But if you do not quote it properly then when
printing it the '*' may be expanded as a file glob.
Case 1 (fail, insufficient quoting):
$ echo $ss
Case 2:
$ echo "$ss"
The first case will expand the variable on the command line. Then
because it is not quoted it will do file glob expansion. During the
file glob expansion the '*' will be expanded. Therefore it is
necessary to quote it as in the second correct case.
I think the problem you experienced happened when you printed the
contents and not during the variable assignment.
Bob