Invalid back reference


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Invalid back reference
# 1  
Old 11-01-2012
Invalid back reference

The thread can be closed now Smilie.

Last edited by vaz0r; 11-01-2012 at 03:00 PM..
# 2  
Old 11-01-2012
Code:
egrep '\[.*>\+{8}.*\]' file

Just out of curiosity, is that code fragment written in brain f***?
This User Gave Thanks to balajesuri For This Post:
# 3  
Old 11-01-2012
Quote:
Originally Posted by vaz0r
I tried using the following expression:
Code:
 egrep '.*\[.*>\(........\).*\].*\.>\1\.' file

Unfortunately I received the following error message: 'egrep: Invalid back reference'. Does anyone know what i am doing wrong? Or any suggestions how I could solve this problem?
For two reasons, just use grep, not egrep.

(1) Nothing about your regular expression requires using the extended flavor of regular expression. As a matter of fact, as it's written, it's using the basic flavor. The \( sequence creates a back reference in the basic flavor. In egrep's extended flavor that just matches a literal parenthesis.
(2) POSIX extended regular expressions do not support back references. Your code will probably work with GNU egrep extensions, but will fail with most other egrep. implementations.

Regards,
Alister

Last edited by alister; 11-01-2012 at 02:41 PM..
This User Gave Thanks to alister For This Post:
# 4  
Old 11-01-2012
Now I used grep instead of egrep it works. Thanks alot!
And yes the code was from brainf***.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed - use back reference in 2nd command

I have data that looks like this: <Country code="US"><tag>adsf</tag><tag>bdfs</tag></Country><Country code="CA"><tag>asdf</tag><tag>bsdf</tag></Country> I want to grab the country code save it, then drop each new "<..." onto a new line with the country code added to the beginning of each So,... (9 Replies)
Discussion started by: JenniferAmon
9 Replies

2. UNIX for Dummies Questions & Answers

Extract text in sed using back reference

i have a text 20 21 22 23 24 25 26 i want to get 22 using sed back reference. I have used sed 's/{6}\(..\).*/\1/' but, it does not work. I am missing something somewhere. Please help. (5 Replies)
Discussion started by: gotamp
5 Replies

3. Shell Programming and Scripting

sed back reference error

I am trying to change a single line of a special file whose comment character is ! to show a path to the file in the comment. such as: !!HFSS and mcm path: \Signal_Integrity\Package_SI\Section_Models\C4toTrace\28nm\D6HS\SLC_5-2-5\GZ41_ICZ\NSSS\ to a different path and replace the !!HFSS... (1 Reply)
Discussion started by: mobrien601
1 Replies

4. Shell Programming and Scripting

sed error: invalid reference

Hello all, I am using sed to parse a particular part of a string and am having problems. I am getting the following error: sed: -e expression #1, char 28: invalid reference \1 on `s' command's RHS Here is the code I am using: echo "Alarm SET:" echo "" echo "Date: " $DATE echo... (4 Replies)
Discussion started by: dlundwall
4 Replies

5. Shell Programming and Scripting

Perl de-reference code reference variable

Guys, May i know how can we de reference the code reference variable.? my $a = sub{$a=shift;$b=shift;print "SUM:",($a+$b),"\n";}; print $a->(4,5); How can we print the whole function ? Please suggest me regarding this. Thanks for your time :) Cheers, Ranga :) (0 Replies)
Discussion started by: rangarasan
0 Replies

6. Shell Programming and Scripting

Shell Scripting Problem - Invalid Back Reference

Here is the question... Create a new script, sub2, taking three parameters... 1.) the string to be replaced 2.) the string with which to replace it 3.) the name of the file in which to make the substitution ...that treats the string to be replaced as plain text instead of as a regular... (1 Reply)
Discussion started by: johnhisenburg
1 Replies

7. IP Networking

Back-to-Back Connection using HBAs

Hi every body, Is it possible to connect two servers Back-to-Back (Point-to-Point) using HBA adapters & using Fiber. Note it is direct connection & there is no switches between the servers. I'm concern about using HBA adapters, it is possible or not. Thanks in advance. :) (3 Replies)
Discussion started by: aldowsary
3 Replies

8. Shell Programming and Scripting

Perl: Getting back reference from s modifier

My input text has the following pattens: func_a(3, 4, 5); I want to replace it with this: func_b(3, 4, 5, 6); I'm trying the following expression, but it does not work: perl -p -e "s/func_a\((.*)?\);/func_b(\1,\n6)/s" <... (8 Replies)
Discussion started by: cooldude
8 Replies

9. Shell Programming and Scripting

back reference error

Hi, i am getting this error........ find ./ | sed '/\(*\) \(*\)/\2\1/' Unrecognized command: /\(*\) \(*\)/\2\1/ Any idea??? regards Apoorva Kumar (4 Replies)
Discussion started by: apoorvasharma80
4 Replies
Login or Register to Ask a Question