>>sed -e 's/^....-//g' oldfile | sed -e 's/\/.\/.//g' > newfile
>Does this group have a "useless use of pipes award"?
>(Actually, contestents for the "useless use of cat award"
>could (almost?) always enter the "useless pipes" contest too...)
> sed -e 's/^....-//g' -e 's,/./.,,g' oldfile > newfile
>(I also ameliorated the "leading toothpick syndome" while I was at it.)
Both you guys lost track of the original problem, because these
solutions, while close, don't do the right thing, they eliminate the
leading double quote. There is no need for the g flags either, as
only one substitution per line is desired/wanted.
Here's part of the original post:
| "ABC-12345/X/Y","98-06-02 12:31","983432 99","Some text", "etc..."
| "ABC-54321/Z/Y","98-06-01 10:44","345534 32","Some more text", "etc..."
|
| The first column always begins with "ABC-" and the X,Y and Z is always only
| one character, but I want to get rid of all but the number in the first
| column.
| The number (12345) can be anything between 1-99999 (one to five chars).
|
| The example should look like:
| "12345","98-06-02 12:31","983432 99","Some text", "etc..."
| "54321","98-06-01 10:44","345534 32","Some more text", "etc..."
BTW, if you want to eliminate things, then your expression could be
written more compactly to properly do the job like this:
sed 's/...-//;s,/./.,,' oldfile > newfile
Personally, I prefer this, even though it's longer:
sed -e 's/^"[^"0-9]*\([0-9][0-9]*\)[^"]*"/"\1"/' oldfile > newfile
It takes the field contained by double quotes starting a line and
eliminates everything between the quotes except the first string of
1 or more numbers, when that is possible.
Chuck Demas
Needham, Mass.
--
Eat Healthy | _ _ | Nothing would be done at all,
Die Anyway | v | That no one could find fault with it.