Home > Archive > AWK > July 2004 > Question about sed
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 |
Question about sed
|
|
| Raul B 2004-07-29, 3:55 pm |
| I have thousands of lines as:
TITLE = "Agent.Daily.AccessDenials", UNITS = "Runs",HISTORY_TIME =
"600", HISTORY_SPAN = 0, HISTORY_LEVEL = False,
Where I need to delete all the info that follows the "UNITS" match.
I wonder if there is a way to do this using sed or awk.
Any help would be very helpful.
Regards.
Raul.
| |
| Ian Stirling 2004-07-29, 3:55 pm |
| Raul B <rnrodrig@todito.com> wrote:
> I have thousands of lines as:
>
> TITLE = "Agent.Daily.AccessDenials", UNITS = "Runs",HISTORY_TIME =
> "600", HISTORY_SPAN = 0, HISTORY_LEVEL = False,
>
> Where I need to delete all the info that follows the "UNITS" match.
>
> I wonder if there is a way to do this using sed or awk.
Do you mean:
awk '/UNITS/{
match("^.*UNITS = \"[^\"]*\",$0)
print substr($0,1,RLENGTH)
}
| |
| Ed Morton 2004-07-29, 3:55 pm |
|
Raul B wrote:
> I have thousands of lines as:
>
> TITLE = "Agent.Daily.AccessDenials", UNITS = "Runs",HISTORY_TIME =
> "600", HISTORY_SPAN = 0, HISTORY_LEVEL = False,
>
> Where I need to delete all the info that follows the "UNITS" match.
>
> I wonder if there is a way to do this using sed or awk.
It's easiest in sed:
sed 's/, UNITS =.*$//'
Ed.
| |
| Charles Demas 2004-07-29, 3:55 pm |
| In article <a7cbebc9.0407290905.2b81d3b4@posting.google.com>,
Raul B <rnrodrig@todito.com> wrote:
>I have thousands of lines as:
>
>TITLE = "Agent.Daily.AccessDenials", UNITS = "Runs",HISTORY_TIME =
>"600", HISTORY_SPAN = 0, HISTORY_LEVEL = False,
>
>Where I need to delete all the info that follows the "UNITS" match.
>
>I wonder if there is a way to do this using sed or awk.
>
>Any help would be very helpful.
How about using the commas and deleting everything from the second
comma on:
sed 's/\([^,]*,[^,]*\).*/\1/' infile
Chuck Demas
--
Eat Healthy | _ _ | Nothing would be done at all,
Stay Fit | @ @ | If a man waited to do it so well,
Die Anyway | v | That no one could find fault with it.
demas@theworld.com | \___/ | http://world.std.com/~cpd
| |
| Kenny McCormack 2004-07-29, 8:55 pm |
| In article <cebjm8$6pc@netnews.proxy.lucent.com>,
Ed Morton <morton@lsupcaemnt.com> wrote:
>
>
>Raul B wrote:
>
>
>It's easiest in sed:
>
>sed 's/, UNITS =.*$//'
>
> Ed.
But, of course, completely off topic for this newsgroup.
Win some, lose some.
| |
| Raul B 2004-07-30, 8:55 pm |
| Thanks a lot four help, the solutions that says:
sed 's/, UNIT = .*$//'
was the simplest and the easiest.
Again thanks for your help.
| |
| Charles Demas 2004-07-30, 8:55 pm |
| In article <a7cbebc9.0407301339.2d13ec37@posting.google.com>,
Raul B <rnrodrig@todito.com> wrote:
>Thanks a lot four help, the solutions that says:
>
>sed 's/, UNIT = .*$//'
>
>was the simplest and the easiest.
sed 's/,.*//'
is simpler given what you seem to want.
Chuck Demas
--
Eat Healthy | _ _ | Nothing would be done at all,
Stay Fit | @ @ | If a man waited to do it so well,
Die Anyway | v | That no one could find fault with it.
demas@theworld.com | \___/ | http://world.std.com/~cpd
| |
| Ed Morton 2004-07-31, 3:55 am |
|
Charles Demas wrote:
> In article <a7cbebc9.0407301339.2d13ec37@posting.google.com>,
> Raul B <rnrodrig@todito.com> wrote:
>
>
>
> sed 's/,.*//'
>
> is simpler given what you seem to want.
>
>
> Chuck Demas
>
Good point, maybe I could even redeem myself from earlier with a topical
response ;-):
awk -F, '{print $1}'
but I just can't resist a final OT one too:
cut -d, -f1
For the OP - questions about sed (or cut or any other non-awk tool) are
better directed to comp.unix.shell.
Sorry,
Ed.
|
|
|
|
|