|
Home > Archive > Unix Shell > December 2007 > simple command that just won't work?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
simple command that just won't work?
|
|
|
| I have a simple command that just won't work.
This is in Debian Linux.
Simply want to use sed to make some simple changes to a test file.
Here it is:
sed -e 's/(\d{4}[A-H]\d\d*)/ADDH$1/' *.txt
which, I thought, would put an ADDH in front of the matched
expression.
But nothing happens, and cannot see where my regexp syntax is
incorrect.
Can anyone please show me the error of my ways?
TIA,
rick
| |
| mallin.shetland 2007-11-30, 7:23 pm |
| Rick scrisse:
> I have a simple command that just won't work.
No, you have a syntax error.
Rick scrisse:
> sed -e 's/(\d{4}[A-H]\d\d*)/ADDH$1/' *.txt
``\d'' is a shortcut for [0-9] in VIM regular expression
sed don't support it; use [0-9] instead.
I don't understand `'$1'', if it is a back reference it
have to be ``\1''. And instead of ``(...)'' you should
write ``\(...\)'' delimiting a subexpression.
Also ``\{...\}'' instead ``{...}'' for repetition operator.
Rick scrisse:
> ...
> which, I thought, would put an ADDH in front of the matched
> expression...
If you wish this try:
sed -e 's/[0-9]\{4\}[A-H][0-9]\+/ADDH&/' *.txt
| |
|
| On Nov 30, 5:48 pm, "mallin.shetland" <mallin.shetl...@aol.com> wrote:
> Rick scrisse:
>
>
> No, you have a syntax error.
>
> Rick scrisse:
>
>
> ``\d'' is a shortcut for [0-9] in VIM regular expression
> sed don't support it; use [0-9] instead.
>
> I don't understand `'$1'', if it is a back reference it
> have to be ``\1''. And instead of ``(...)'' you should
> write ``\(...\)'' delimiting a subexpression.
> Also ``\{...\}'' instead ``{...}'' for repetition operator.
>
> Rick scrisse:
>
>
> If you wish this try:
>
> sed -e 's/[0-9]\{4\}[A-H][0-9]\+/ADDH&/' *.txt
thanks dude...that worked like a charm! (& saved me having to write it
in perl!)
| |
| John W. Krahn 2007-11-30, 7:23 pm |
| Rick wrote:
>
> On Nov 30, 5:48 pm, "mallin.shetland" <mallin.shetl...@aol.com> wrote:
>
> thanks dude...that worked like a charm! (& saved me having to write it
> in perl!)
Dude ... you already had perl, it didn't work because you had 'sed -e'
at the beginning instead of 'perl -pe'
John
--
use Perl;
program
fulfillment
| |
| Michael Tosch 2007-12-05, 7:32 am |
| John W. Krahn wrote:
....
>
> Dude ... you already had perl, it didn't work because you had 'sed -e'
> at the beginning instead of 'perl -pe'
>
>
> John
ROFL - Dude, that was a good one!
--
Michael Tosch @ hp : com
|
|
|
|
|