The UNIX and Linux Forums
>
Top Forums
>
Shell Programming and Scripting
Problem in extracting vector data
.
User Name
Remember Me?
Password
google unix.com
Forums
Register
Forum Rules
Links
Albums
FAQ
Members List
Calendar
Search
Today's Posts
Mark Forums Read
Thread
:
Problem in extracting vector data
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
#
2
(
permalink
)
03-18-2008
era
Guest
Posts: n/a
Bits:
0
[
Banking
]
Please add some more hints. Is file B always a single line? Do you want to do this in the Enterprise Silver Platinum Mojo Beans way or just a one-off job?
Code:
sed
-e 's/.*/s%^.*\\(<[^<>]*>\\).*%\\1 \* &%/' fileB |
sed
-f - fileA
In the famous words of Dennis M. Ritchie, You Are Not Supposed to Understand This.
Actually, as a brief overview, we are taking the contents of fileB (presumably a single line) and wrapping it inside some
sed
commands, which are then passed as a script to
sed
to run on fileA. Conveniently, the first
sed
writes a script for the second containing the contents of fileB and a bit of
sed
trickery. It's not even tricky at all, once you wrap your head around it (and decode the escapes needed to prevent the literal parts in the first script from being interpreted by the first
sed
).
Last edited by era; 03-18-2008 at
03:23 AM
.. Reason: I forgot to add a plus on all lines but the first, but maybe that can be left as an exercise ...
era
Find 's past nominations received
Find 's present nominations given