Re: [SLUG] text manipulation

From: bill@thegliddenfamily.com
Date: Mon Jan 07 2008 - 14:49:00 EST


Original Message:
-----------------
From: Matthew Rogers matt@runithard.com
Date: Mon, 07 Jan 2008 09:46:37 -0500
To: slug@nks.net
Subject: Re: [SLUG] text manipulation

steve szmidt wrote:
> On Monday 07 January 2008, Eben King wrote:
>
>> Hey scripters:
>>
>> 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.
>>
>> I tried sed (specifically the "H" and "x" commands), but it seems my
sed-fu
>> is lacking. "paste"?
>>
>
> You could read it into a variable, then parse it. Depending on amount of
data
> this works:
>
> You have a file with:
> url1
> file1
> url2
> file2
> url3
> file3
> url4
> file4
>
> The script:
>
> #!/bin/sh
> #
> Data=`cat datalist`
> Count=1
> echo "" > sortedlist
> for URL in $Data ; do
> if [ "$Count" -eq "1" ] ;then
> Line="$URL"
> else
> echo "$Line $URL"
> echo "$Line $URL" >> sortedlist
> Line=""
> Count=0
> fi
> Count=$(($Count+1))
> done
> echo
> echo "Result file:"
> cat sortedlist
>
> The sortedlist:
> url1 file1
> url2 file2
> url3 file3
> url4 file4
>

My lazy man's version:

#!/bin/sh
while read URL
do
   read FILENAME
   echo "$URL $FILENAME"
done

cat the input file to this script and redirect the output

--------------------------------------------------------------------
mail2web.com – What can On Demand Business Solutions do for you?
http://link.mail2web.com/Business/SharePoint

-----------------------------------------------------------------------
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:01 EDT