-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
iQEcBAEBCgAGBQJTarNHAAoJEERGtGilKM7wVpwIAIY5dS0JtXaNvI4jzeHufJKj
I1Y9TENfxBPUNhBFzTnpgfX4ZjDQgxfLnXf2BZzQHXVK6HoRijS/d+AdPBH8tnfy
TZc41XyKmmZjRaZvJ8jKE34JxtXQaEzr7vvIDMFQaoP8x/krfOUxZy5eGMSulNI2
TZxZKG1NOneOnh8w+v4ZmBfL/CLbQQJYY1mJuUhyamK98IBwrpbeRn0JduVuVdKo
dmg4gSbzTOZOv2BoqRt6ChXHQRlJy80jOZQ4IROT82pHXghIXIOqNj4C1N1kbK6R
czhyX5MBuo0/H8oY+ofLRvUW6BSnPy8ZP9wAXuNZn2qbeAGrNPBI7ZWzMe4L0qA=
=25Mb
-----END PGP SIGNATURE-----
On 2014-05-07 09:07, Nerdio wrote:
> I have a requirement which I am sure I can do in vi (plenty of
> other solutions I am sure), and this is it.
>
> I have a file that looks like this
>
> 1234 Some Text HERE rest of line
> 1235 Some Other Text HERE rest of line
>
> What I want to do is delete text from, and including the word HERE
> to the end of the line, leaving me with this;
>
> 1234 Some Text
> 1235 Some Other Text
>
> I have done search and replace things in vi, but am not sure how to
> do a search then run a command.
Since your command merely consists of deleting to the end of the
line, you can search for your string, followed by anything, and it
will delete:
:%s/HERE.*
or, if you want to make sure:
:%s/HERE.*//c
(which will prompt you for each one).
Additionally, it looks like you have some whitespace before your
"HERE", so you might actually want
:%s/\s\+HERE.*
which will clean that up as well.
-tim
Wednesday, May 7, 2014
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment