Tricky egrep


 
Thread Tools Search this Thread
Operating Systems Solaris Tricky egrep
# 1  
Old 03-11-2011
Question Tricky egrep

Hi folks!

My first post here.

I'm working on a script that retrieves a range of files from a list depending on a range of time.
UPDATE:
I've seen it could be difficult to read all this thing, so I'll make a summarize it..

How come I do this and take a result..
Code:
grep "..\:.." lista.new | egrep 'Mar 10 ((1[4-9]|2[0-9]|3[0-4]):([5-5][4-9]|[4-5][0-9]))|Mar 11 (([0-1][0-4]:[0-5][0-4])|([0-1][0-3]:[0-5][0-9]))'
drwxr-x---   3 atxiph   was6gp        20480 Mar 11 11:11 PRUEBAS_SENTINESI
drwxr-x---   3 atxiph   was6gp        20480 Mar 10 23:51 PRUEBAS_SENTINESI
drwxr-x---   3 atxiph   was6gp        20480 Mar 10 18:51 PRUEBAS_SENTINESI

..and this does nothing?

Code:
grep "..\:.." lista.new | egrep '$comando'

knowing thet $comando is the same egrep..
Code:
echo $comando
Mar 10 ((1[4-9]|2[0-9]|3[0-4]):([5-5][4-9]|[4-5][0-9]))|Mar 11 (([0-1][0-4]:[0-5][0-4])|([0-1][0-3]:[0-5][0-9]))

Ideas?

Last edited by kl0x; 03-11-2011 at 10:09 AM..
# 2  
Old 03-12-2011
Quote:
Originally Posted by kl0x
Hi folks!

How come
.
.
.this does nothing?

Code:
grep "..\:.." lista.new | egrep '$comando'

knowing thet $comando is the same egrep..
[CODE]Ideas?
No shell will look inside single quotes. Try this:
Code:
echo '$comando'

instead of
Code:
echo $comando

to see what egrep is seeing.
# 3  
Old 03-12-2011
Hi!

Thank you for your reply. The thing is that the egrep doesn't work, the echo works fine (It's just to make sure that $comand is the correct string).

So egrep '$comand' won't work while egrep 'inside of $comand' will..

I'm not able to see it!Smilie
# 4  
Old 03-12-2011
Your echo works "fine" because you have no single quotes. (Actually, it has mislead you.) Now go and try the alternate echo I gave you. The one with the single quotes. This is the echo that will show you what is happening.
# 5  
Old 03-12-2011
I got you, I'll try to find how to do it, thx

---------- Post updated at 06:17 PM ---------- Previous update was at 06:13 PM ----------

Ok I got it like this:
Code:
grep "..\:.." lista.new | egrep "$comando"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parsing xml - tricky one...need help!!

Hi, i am new to linux programming fraternity but looks like starting with a big thing... yes..xml parsing (it is indeed tough for a beginner like me) so need your kind help... The snippet of xml looks like: <snapshot> <tag1> <key>1234</key> <keytype>abcd</keytype> </tag1> <tag2>... (11 Replies)
Discussion started by: rookie2014
11 Replies

2. Shell Programming and Scripting

Tricky sed required

Hi All I need to put some sed together for a task and its a bit advanced for me, so I thought I'd ask if anyone here could help. I have a csv file with content like this - "","abcde","","" "'","abcde","","" "","","","1234" "'e'","","","" I need to remove any single quotes that fall... (17 Replies)
Discussion started by: steadyonabix
17 Replies

3. UNIX for Dummies Questions & Answers

Tricky GREP question..

I have some large login files that I need to extract (user)@(server) from. Where it gets tricky is that there is usually more than one '@' sign on each line(although it does have a leading space if it's not part of the (user)@(server) string), I need only the (user)@(server) section, I need only... (6 Replies)
Discussion started by: Mordaris
6 Replies

4. UNIX for Dummies Questions & Answers

tricky file output

I have a following file, I want to output 2 files. Is that easy to do? Output 1 output2 Thanks (4 Replies)
Discussion started by: jbchen
4 Replies

5. UNIX for Dummies Questions & Answers

search ")" with egrep - egrep: syntax error

Hi Guys, we have a shell script which basically query the Database which retrieves huge data and use the data with "egrep" . Now there is some data which contains characters like "abc)" and the same is used like below : "egrep (.+\|GDPRAB16\|GDPR/11702 96 abc)\|$ temp.txt" now while... (7 Replies)
Discussion started by: sagarjani
7 Replies

6. UNIX for Dummies Questions & Answers

Egrep cheat sheet anywhere? Looking for meaning of egrep -c

Hi I've been searching google and have not found what egrep -c means. Does anyone know where I can get a cheat sheet or what that -c means? thanks, Linda (2 Replies)
Discussion started by: leelm
2 Replies

7. Shell Programming and Scripting

Tricky Shell script

The Problem is mentioned below (61 Replies)
Discussion started by: namishtiwari
61 Replies

8. Shell Programming and Scripting

Tricky script question

Hi, I'm in the midst of writing a UNIX script that sftp's files to an external host and am stuck with a problem. The problem is that the files created on my server as a order number that correlates to a sequence of directories on the remote host which is where the file should be ftp'ed. ... (3 Replies)
Discussion started by: budrito
3 Replies

9. Shell Programming and Scripting

Tricky Sed

Hello. I am trying to convert occurrences of 'NULL' from a datafile. The 'NULL' occurences appears at this: |NULL| NULL|NULL| NULL|NULL| NULL|NULL| NULL| There should be 52 fields per line. I would like any occurrence of | NULL| or |NULL| to appear as '||' Currently I am using this sed... (2 Replies)
Discussion started by: bestbuyernc
2 Replies

10. Windows & DOS: Issues & Discussions

Tricky one...

Here's my problem: I have a laptop running Windows XP Pro with no internal CD or Floppy drives. I want to install Linux on it. I don't care about the Windows XP Pro installation, in fact I would like to install Linux over the entirety of the HD. However I cannot boot from any external CD drive... (1 Reply)
Discussion started by: saabir
1 Replies
Login or Register to Ask a Question