Why does '$$' means an empty line in agrep -d '$$'


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Why does '$$' means an empty line in agrep -d '$$'
# 1  
Old 02-18-2009
Why does '$$' means an empty line in agrep -d '$$'

Hi all,

Why does '$$' means an empty line in agrep -d '$$'. I did not know that '$$' can be seen as an empty line in regular expression. So did I miss something here ?

Thanks!
# 2  
Old 02-18-2009
It looks like a bug. Contact the authors.

PS: By "empty line", you mean the end of the line, right?
Code:
$ grep 's$$' /etc/hosts
$ agrep 's$$' /etc/hosts
# Do not remove the following line, or various programs
$$ agrep --version
agrep (TRE agrep) 0.7.5

Copyright (c) 2002-2006 Ville Laurikari.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# 3  
Old 02-18-2009
Actually, wait a minute. I just remembered agrep uses the PCRE, and lo-and behold, grep -P returns the same thing! But perl does not have the bug. So either it's in the Perl-compatible regular expression libary, or it's in the parsing.
Code:
$ grep -P 's$$' /etc/hosts
# Do not remove the following line, or various programs
$ perl -n -e 'print if /s$$/;' /etc/hosts
$

# 4  
Old 02-18-2009
my solaris grep version seems to work if you do this:
Code:
grep 'a\$\$' file

# 5  
Old 02-18-2009
By empty line I mean a new line without any characters

Thanks for the reply.

By empty line I mean a new line without any characters (just ~n).
It is not just TRE agrep, for all the agrep versions I find, all their help files come with an example like this,

agrep -d '$$' pattern foo will output all paragraphs (separated by an empty line) that contain pattern.


Either they just copy paste the example or we did miss something here and $$ does mean "empty line". I feel really confused now.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line...

Hello, I need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line... An example of entries in the file would be: SRVXPAPI001 ERRO JUN24 07:28:34 1775 REASON= 0000, PROCID= #E506 #1065: TPCIPPR, INDEX= 003F ... (8 Replies)
Discussion started by: Ferocci
8 Replies

2. Programming

[SOLVED] C++ print next line until line.empty

Hi, could you please help with the following: I have an input file like: one two three four five six I want to print the lines starting from 'three' to the empty line. Something like that: if ( line == "three" ) { while ( !line.empty() ) { cout <<... (0 Replies)
Discussion started by: apenkov
0 Replies

3. Shell Programming and Scripting

I need to know how to replace a line after a pattern match with an empty line using SED

Hi How Are you? I am doing fine! I need to go now? I will see you tomorrow! Basically I need to replace the entire line containing "doing" with a blank line: I need to the following output: Hi How Are you? I need to go now? I will see you tomorrow! Thanks in advance.... (1 Reply)
Discussion started by: sags007_99
1 Replies

4. Shell Programming and Scripting

Fill the empty line by adding line before blank line

FIle A "A" 2 aa 34 3 ac 5 cd "B" 3 hu 67 4 fg 5 gy output shud be A"" 2 aa 34 "A" 3 ac 34 "A" 5 cd 34 "B" 3 hu 67 "B" 4 fg 67 "B" 5 gy 67 (6 Replies)
Discussion started by: cdfd123
6 Replies

5. Shell Programming and Scripting

howto add line as a first line into a non empty file

Hi Trying to do like this : echo "$variable1\n $(cat file.txt)" but it only adds one time. When I run this cmd again with different variable it only replaces line of variable1. How to add constantly line into first line in file ? (3 Replies)
Discussion started by: presul
3 Replies

6. Shell Programming and Scripting

How to specify two delimiters in agrep for record definition ?

Hi all, How to specify two delimiters in agrep for record definition, one for the beginning of the record and the other for the end ? Most of examples I see so far only specify 1 delimiter, e.g. agrep -d '^From ' 'pizza' mbox. But that won't work for me. I need to 2 delimiters to indicate the... (2 Replies)
Discussion started by: qiulang
2 Replies

7. Shell Programming and Scripting

Please let me know what this line in cron means?

Hi All, I found this line in my crontab.. 0 6 * * * "some script name" my question is it means the script should run at 6 00 am. But on what those days are not mentioned. Then in that case when will the script will run? Thanks for ur help in advance, Magesh (3 Replies)
Discussion started by: mac4rfree
3 Replies

8. Shell Programming and Scripting

agrep: pattern too long

agrep -d Seconds "29 06 0e 2b 06 01 04 01 9d 64 03 08 02 01 05 05" filename agrep: pattern too long Guys, I am trying to grep for some data in a flat ascii file and I get this error, can someone please help me out (3 Replies)
Discussion started by: knijjar
3 Replies

9. Shell Programming and Scripting

empty line

new problem comes out.. unix script calls sql script and save the output into a file. but now there are many empty lines in the output file. first line is empty and follow by 13 rows of data and another empty line and data and so on.. how can I fix that? thanks (4 Replies)
Discussion started by: YoYo
4 Replies
Login or Register to Ask a Question