back reference error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting back reference error
# 1  
Old 08-22-2006
back reference error

Hi,

i am getting this error........

find ./ | sed '/\([a-z]*\) \([a-z]*\)/\2\1/'
Unrecognized command: /\([a-z]*\) \([a-z]*\)/\2\1/


Any idea???

regards
Apoorva Kumar
# 2  
Old 08-22-2006
Yes, you aren't telling sed what command to execute! The regex is fine (haven't looked into the details), but sed needs to know what to do with the match if/when it finds it. i.e. If you want to just print the matching patterns, you still have to tell it to print them using the 'p' command.

Last edited by blowtorch; 08-22-2006 at 07:32 AM..
# 3  
Old 08-22-2006
thanks partner!!..I just missed to put a s there.

I have few file in my dir.....

abc 123
efg 567

I am trying this command.....

for file in `find ./|sed 's/^/\"/'|sed 's/$/\"/'`
do
echo $file
done

This is the output i am getting.........

"./"
"./.sh_history"
"./3rdPartytesting"
"./abc
123"
""
"./efg
456"
"./bkup"


The issue is there is an extra \n in the names of files which contains a space in them. Can you help me get a output like...

"./"
"./.sh_history"
"./3rdPartytesting"
"./abc 123"
""
"./efg 456"
"./bkup"

regards
Apoorva Kumar
# 4  
Old 08-22-2006
Quote:
Originally Posted by apoorvasharma80
thanks partner!!..I just missed to put a s there.

I have few file in my dir.....

abc 123
efg 567

I am trying this command.....

for file in `find ./|sed 's/^/\"/'|sed 's/$/\"/'`
do
echo $file
done

This is the output i am getting.........

"./"
"./.sh_history"
"./3rdPartytesting"
"./abc
123"
""
"./efg
456"
"./bkup"


The issue is there is an extra \n in the names of files which contains a space in them. Can you help me get a output like...

"./"
"./.sh_history"
"./3rdPartytesting"
"./abc 123"
""
"./efg 456"
"./bkup"

regards
Apoorva Kumar

Please any anwers??

regards
Apoorva Kumar
# 5  
Old 08-22-2006
Pls don't bump-up posts if not answered immediately!
Code:
find . | sed 's/.*/"&"/'


Last edited by vgersh99; 08-22-2006 at 11:39 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 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. Programming

Error: undefined reference to winmain@16?

I was trying to compile the following code in cygwin using g++: ------------------------------------------ #include <iostream> using namespace std; int identity(int input) { int output = input; return output; } ------------------------------------------ I get this error: ... (7 Replies)
Discussion started by: DyslexicChciken
7 Replies

5. UNIX for Dummies Questions & Answers

Invalid back reference

The thread can be closed now :D. (3 Replies)
Discussion started by: vaz0r
3 Replies

6. 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

7. 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

8. 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

9. 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

10. Programming

Undefined reference to Error

Hello, plz help me out with this error, i am getting this error when i compile my code with gcc. /usr/lib/gcc-lib/i386-redhat-linux/3.3.2/../../../crt1.o(.text+0x18): In function `_start': : undefined reference to `main' /tmp/cciLxqdV.o(.text+0x3c): In function `HandleUserTransaction()':... (2 Replies)
Discussion started by: svh
2 Replies
Login or Register to Ask a Question