How to grep sting (*) ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to grep sting (*) ?
# 1  
Old 05-04-2010
Debian How to grep sting (*) ?

Hi all,
I am trying to grep something from log file.


For example. i need to grep sting = "*834*1"


My LOG


Code:
2010-05-05 09:27:57,649|3|ABCD834|192.168.38.72|2365|444850623031|0|8|-|0|*834*1*1499413*00853662524#|470540.7219101273026475158
2010-05-05 09:28:48,053|12|ABCD834|192.168.38.71|147|444804255165|0|16|-|0|*834*9*4*00853662730#|434120.7196481273026527726
2010-05-05 09:28:58,460|5|ABCD834|192.168.38.76|608|444854069949|0|10|-|0|*834*5*00853663028#|371780.1682631273026537677
2010-05-05 09:29:05,822|5|ABCD834|192.168.38.72|575|444804255165|0|10|-|0|*834*5*00853662730#|482760.7235481273026545257
2010-05-05 09:29:17,703|13|ABCD834|192.168.38.76|5175|444854069949|-1|0|30105|0|*834*9*5*00853663028#|330870.1692111273026552253
2010-05-05 09:29:20,250|6|ABCD834|192.168.38.71|80|444804255165|0|11|-|0|*834*6*00853662730#|358980.7103851273026559517
2010-05-05 09:29:29,235|7|ABCD834|192.168.38.71|60|444804255165|0|29|-|0|*834*7*00853662730#|359290.7105931273026568788
2010-05-05 09:29:48,820|13|ABCD834|192.168.38.76|308|444854069949|0|17|-|0|*834*9*5*00853663028#|477350.1615001273026588532
2010-05-05 09:30:05,759|14|ABCD834|192.168.38.76|228|444854069949|0|18|-|0|*834*9*6*00853663028#|403290.1625021273026605443
2010-05-05 09:30:31,176|14|ABCD834|192.168.38.73|277|444850369726|0|18|-|0|*834*9*6*00868434710#|649800.1317031273026630789
2010-05-05 09:32:18,359|0|ABCD834|192.168.38.72|2|444824692738|-1|3|00999|0|*834#|566550.7282441273026737801

out put
Code:
2010-05-05 09:27:57,649|3|ABCD834|192.168.38.72|2365|444850623031|0|8|-|0|*834*1*1499413*00853662524#|470540.7219101273026475158

# 2  
Old 05-04-2010
Code:
grep "\*834\*1" "My LOG"

# 3  
Old 05-05-2010
Surround the * with single quotes. It prevents expansion.

Code:
grep '*834*1' MY_LOG

# 4  
Old 05-05-2010
Quote:
Originally Posted by vino
Surround the * with single quotes. It prevents expansion.

Code:
grep '*834*1' MY_LOG

This won't work. The issue isn't file expansion but "*834*1" doesn't matching "*834*1" as a limited regular expression.

alternatively, this will work too:
Code:
fgrep "*834*1" MY_LOG

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Inconsistent `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l`

i have this line of code that looks for the same file if it is currently running and returns the count. `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l` basically it is assigned to a variable ISRUNNING=`ps -eaf -o args | grep -i sfs_pcard_load_file.ksh |... (6 Replies)
Discussion started by: wtolentino
6 Replies

2. Shell Programming and Scripting

Awk to search for sting in lines and then email.

I'm trying to use awk in a script to search for a string number in a plist file. basically its a plist that records the bandwidth usage, and if the number is greater than 3GB which is equals 3221225472 bytes, it will send me an alert by email. here is the file: =<?xml version="1.0"... (4 Replies)
Discussion started by: ivaldiz
4 Replies

3. Shell Programming and Scripting

Find and replace a string in group of sting

Hi, 1. I want to remove the line which contains "SUBPARTITION", but the condition is if line has ends with ")," replace with , else delete the line I was trying with the sed command i... (3 Replies)
Discussion started by: gavemani
3 Replies

4. Shell Programming and Scripting

Replace sting in a file

Hi Gurus, I need to search and replace string <! in a file with a blank. Some how my command sed -i 's/\<\!\ is not working .. Kindly help (1 Reply)
Discussion started by: r_t_1601
1 Replies

5. Shell Programming and Scripting

Inserting a string in another sting

Hi Experts, I need to insert a sting into another string at a specified position. Like the below. Regards, Tin-Tin (3 Replies)
Discussion started by: tinufarid
3 Replies

6. Programming

Java sting up path problem

Hi java programmers I'm a newbee to the Java. Could please help me to set the path correctly. I'm getting the following error. ----jGRASP exec: javac -g C:\Documents and Settings\bogugk\Desktop\HelloWorldApp.java ----jGRASP wedge2 error: command "javac" not found. ---- This command... (1 Reply)
Discussion started by: repinementer
1 Replies

7. UNIX for Advanced & Expert Users

if 4th and 5th character of sting -ge 45 then add 1 to 3rd character

I want to know how to, given a string like W87151WR71C, if the 4th and 5th character (in this case 15) are greater than 45, then to add 1 to the 3rd character (in this case 7) and assign the revised string the variable name MODSTRING. Thanks in advance. This is ultimately to grab info from... (6 Replies)
Discussion started by: glev2005
6 Replies

8. Shell Programming and Scripting

Assign a sting to a name?

i want to assign a anme for a string, i got the things below, but it doesn't work. MParc1=`` if then $MPrac1=`Prac1` # assign $MPrac1 to Prac1 else $MPrac1=`` #assigne $MPrac1 to nothing fi echo "${MPrac1} >>file Output: (if num is 0) Prac1 can you please... (6 Replies)
Discussion started by: mingming88
6 Replies

9. Shell Programming and Scripting

Extracting value from a sting using perl

Hi Experts, I want to extract the value of SESSIONID AND USERID from the this string using perl. XML Request },&quot;USER_PREF&quot;:{&quot;sys_lang&quot;:&quot;en-us&quot;,&quot;timezone&quot;:&quot;480&quot;,&quot;user_lang&quot;:&quot;en-us&quot;}}}</DEVICESIG></POLICYREQ>] The answer should be SessionID=1:3133050 and USERID=01451651 Please advise how... (3 Replies)
Discussion started by: namishtiwari
3 Replies

10. Shell Programming and Scripting

Verifying sting format in bash

Hello, This one has me stumped, although I suspect it might be easy. I have a file and need to split the entries into two varaibles. The format for a positive is 'AANNNN' where A is alpha and N is numeric. Thanks in advance (5 Replies)
Discussion started by: 98_1LE
5 Replies
Login or Register to Ask a Question