Thursday, 15 January 2015

regex - sed backreferences returning their numerical index rather than their value -


Here is a strange problem that I do not see duplication elsewhere, so post here. thank you in advanced.

I have the following Multilingual Sed Code that is being copied and copied to another script in a script (and then using a script to write a code in a script). The code looks like this:

  sed -i -r '/ (rpub) ([$] [a-zA-Z0-9]) / I \ sed -i' \ '/ # PBS-N / D '' 1 \ "$ 1 $ cp \ 1 '" $ $ $ $ $ $ $ $ $ $ 

1.) Open Master Script. 2.) Navigate to every example of $ [a-zA-Z0- 9] RPUU in script. 3.) Enter the second line (SAD) and the third line (CP) as the first RPV rows, from 1 to 1 $ in the form of backbreaking of $ [a-zA-Z0- 9], from step 1.

This works very well; All the lines print very well in relation to each other, however, all my \ 1 references are being clearly displayed, their backslas from zero are all displayed as 1 in 1.

I know that my pattern match specifications are working correctly, because they fill all instances of RPU $ [a-zA-Z0- 9], but I suppose Is it that I just can not understand the use of the Bakerians? Anyone is watching what is happening here?

Thanks

Edit 1

Special thanks to Ed Morton below, the following is applicable, which is 99% closer to me , But I still can not close the gap with unexpected behavior:

  awk -v fv = "$ filevariable" 'match ($ 0, / rpub ([$] [[: Alnum:]], / a) {print "sed -i '' '/ # PBS-N / D' '', a [1]} 1 '' $ master script" & gt; tmp file & amp; amp; ; Mv tmpfile "$ masterscript"  

Note: I removed a printed print statement because it is here But, as I said, though it comes very close to me, I'm still having an issue where printed lines appear between each line in the master script; It seems that the mailing function is a match on every line It is my fault, as I should have specified that I would like to have the following:

  Goods here on the RPU The luggage named "$$" here is here:  

will be:

  The stuff here named here $ name $ rpub $ $ Alias ​​rpub $ alias  

Any help will be greatly appreciated. Thanks!

It seems that whatever you are trying to do can be written just in awk :

  awk -i inplace -v fv = "$ filevariable" 'match ($ 0, / rpub ([$] [[: alnum:]]), a) {print "sed -i \ "/ # PBS-N / D \", a [1] print "CP", a [1], FV) 1 '' $ MasterScript " 

And without expected output it is just an estimate.

GNU uses 3 RG for awk and match () for the above editing.


No comments:

Post a Comment