Re: [SLUG] text manipulation

From: Scotty Logan (scotty@catbert.net)
Date: Mon Jan 07 2008 - 18:29:41 EST


On Jan 6, 2008, at 11:27 PM, Eben King wrote:
> What can I run text through that'll change it from
>
> url1
> filename1
> url2
> filename2
>
> to
>
> url1 filename1
> url2 filename2
>
> Strictly speaking, it doesn't have to be in that format as long as I
> can use both parts in the same command.

Just pipe the text through awk, or pass the filename as an argument
after the code:

% awk '{if (NR % 2) { u=$0;} else { print u,$0; }}' file

For your example:

% printf 'url1\nfilename1\nurl2\nfilename2\n' | awk '{if (NR % 2) { u=
$0;} else { print u,$0; }}'
url1 filename1
url2 filename2
%

  Scotty

-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS). Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 20:13:34 EDT