script to grep number


 
Thread Tools Search this Thread
Operating Systems Linux script to grep number
# 1  
Old 01-17-2011
script to grep number

hi all,

i would like to create a script that would grep the number in the following pattern

xx xx xx xx xx xx

note that xx are numbers.

i would grep in information in a .rep file.

can i get an idea how to do it

thanks
# 2  
Old 01-17-2011
substitute "xx" for your number
Code:
 $ ruby -ne 'print if $_["xx"]' file

# 3  
Old 01-17-2011
Do you mean any number in that pattern ? If so...
Code:
grep "[0-9][0-9] [0-9][0-9] [0-9][0-9] [0-9][0-9] [0-9][0-9] [0-9][0-9]" filename.rep

# 4  
Old 01-17-2011
Try...
Code:
grep '[0-9][0-9] [0-9][0-9] [0-9][0-9] [0-9][0-9] [0-9][0-9] [0-9][0-9]' *.rep

# 5  
Old 01-17-2011
yeah the pattern like for eg 01 02 03 04 05 06 .

i would like to have an option to input the number(01 02 03 04 05 06), then it goes through the xxx.rep it show me the required information...
# 6  
Old 01-17-2011
Code:
#!/bin/ksh
echo "Enter the search patterh: "
read a
grep "$a" *.rep

# 7  
Old 01-17-2011
thanks will try and let you knoe
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep lines for number greater than given number

Hello, I am newbie to bash scripting. Could someone help me with the following. I have log file with output as shown below **************************LOG************************* 11/20/2013 9:11:23.64 Pinging xx.xx.xx.xx with 32 bytes of data: 11/20/2013 9:11:23.64 Reply from xx.xx.xx.xx:... (4 Replies)
Discussion started by: meena_2013
4 Replies

2. Shell Programming and Scripting

Grep for a Number in a String

Hi, I have variable called fname that has the value M201401151630_P008949.csv.txt I need to grep and store this in a variable called prcid for the number before ".csv" and the letter "P" excluding all zeros in the beginning. Desired output 8949 Likewise for M201401151630_P108949.csv.txt... (12 Replies)
Discussion started by: mohtashims
12 Replies

3. Shell Programming and Scripting

grep number and sent out e-mail

ps -ef |grep /usr/sbin/qdaemon root 5034194 385266 0 Oct 26 - 1:57 /usr/sbin/qdaemon root 7639132 2523220 0 15:25:58 pts/10 0:00 grep /usr/sbin/qdaemon ps -ef |grep /usr/sbin/qdaemon |wc 2 18 145 I need to send out e-mail if the count of the lines... (9 Replies)
Discussion started by: Daniel Gate
9 Replies

4. UNIX for Dummies Questions & Answers

grep any number of spaces

which one of the following is the correct expression to ignore line with multiple spaces after any string cat file | grep -v "xyz *$" or cat file | grep -v "xyz*$" do i need "*" to specify the sapce or " *" will do? (2 Replies)
Discussion started by: manishma71
2 Replies

5. Shell Programming and Scripting

grep the number of self process

Dear All, I plan to write a script and in the beginning, I will check if there's any existing previous process running, if YEs, then exit directly, if Not, then continue. #!/bin/bash NUM=`ps -ef | grep $0 | grep -v grep | wc -l` ps -ef | grep $0 | grep -v grep echo "NUM ==> $NUM" if... (6 Replies)
Discussion started by: tiger2000
6 Replies

6. UNIX for Dummies Questions & Answers

Grep by column number

I have a data file that is arranged like this: Marketing Ranjit Singh Eagles Dean Johnson FULL Marketing Ken Whillans Eagles Karen Thompson FULL Sales Peter RobertsonGolden TigersRich Gardener PART President Sandeep Jain Wimps Ken Whillans CONT... (7 Replies)
Discussion started by: hitman247m
7 Replies

7. Shell Programming and Scripting

Grep for a negative number

Hi, I want to search for a return code of -3. Using grep "-3" *.* is giving a syntax error. Please suggest as to how can we search for this pattern using grep. Thanks, Krishna (2 Replies)
Discussion started by: kzmatam
2 Replies

8. UNIX for Dummies Questions & Answers

grep the number of first occurence

File1.txt ....... ....... OMC LA OMC LK OMC LS ........ ........ Above is the content of File1.txt, i want to get the Number of Occurence to order, lets say if OMC LA = 1, OMC LS=3, and OMC LK=2.. omc_ident="OMC LA" or "OMC LK" or "OMC LS" omc_num=`grep '^OMC' File1.txt| grep... (4 Replies)
Discussion started by: neruppu
4 Replies

9. UNIX for Dummies Questions & Answers

using Grep for only a certain number of columns

I am given a file with a list of names for the first 20 characters. The 20 characters after is a list of names that somebody is supposed to team up with. Now i'm trying to write a simple script that will read a name somebody inputs and then looks only in the first 20 characters. For example.... (2 Replies)
Discussion started by: MaestroRage
2 Replies

10. Shell Programming and Scripting

How to grep a number in a file name

Hi, I have multiple files where it starts with test1.c, test2.c,test3.c and so on. I would like to get each file separately to perform abstraction from these files. I tried something like:- for t in ./* filenumber=${t:4} # to cut the "test" in order to get the number cat... (3 Replies)
Discussion started by: ahjiefreak
3 Replies
Login or Register to Ask a Question