[ale] bash, sed substitution brain baker
Jim Kinney
jim.kinney at gmail.com
Tue Oct 27 13:28:55 EDT 2009
awk wins!
awk -F"," '{ test["blue"] = "sky"; test["pizza"] = "onion" }; {print
$1","$2","$3","$4","test[$5]","$6","test[$7]}' <testfile
abc.com,123,23,100,sky,10.0.1.2,onion
cat testfile
abc.com,123,23,100,blue,10.0.1.2,pizza
awk -F"," '{ test["blue"] = "sky"; test["pizza"] =
"onion";test["green"]="beans";test["fruit"]="banana" }; {print
$1","$2","$3","$4","test[$5]","$6","test[$7]}' <testfile
abc.com,123,23,100,sky,10.0.1.2,onion
fred.badip.us,220,123,25,beans,172.0.0.2,banana
cat testfile
abc.com,123,23,100,blue,10.0.1.2,pizza
fred.badip.us,220,123,25,green,172.0.0.2,fruit
On Tue, Oct 27, 2009 at 12:18 PM, Jim Kinney <jim.kinney at gmail.com> wrote:
> columns 5 and 7 each have about 6-10 different values available. Each
> value is exactly mapped to an index number. Some value indexes are
> shared between two different values (within the same column).
>
> So col 5 may need 2,3,5,9 substituted in while col7 may need
> 3,5,9,16,21 substituted in.
>
> The cols are fixed (although the actual ordering can be changed and
> accommodated for in the processing) and the values in the cols are not
> going to be mixed but they may be duplicates.
>
> On Tue, Oct 27, 2009 at 12:09 PM, Richard Bronosky <Richard at bronosky.com> wrote:
>> The numbers that go in columns 5 and 7 never have different strings
>> associated depending on which column they are in?
>>
>> On Tue, Oct 27, 2009 at 11:54 AM, Jim Kinney <jim.kinney at gmail.com> wrote:
>>> awk is certainly allowed. sed fu is good but WORKING SOLUTION is better!
>>>
>>> On Tue, Oct 27, 2009 at 11:38 AM, Ed Cashin <ecashin at noserose.net> wrote:
>>>> If this is an exercise in sed-fu, does that mean awk isn't allowed? :)
>>>>
>>>> --
>>>> Ed Cashin <ecashin at noserose.net>
>>>> http://noserose.net/e/
>>>> http://www.coraid.com/
>>>> _______________________________________________
>>>> Ale mailing list
>>>> Ale at ale.org
>>>> http://mail.ale.org/mailman/listinfo/ale
>>>> See JOBS, ANNOUNCE and SCHOOLS lists at
>>>> http://mail.ale.org/mailman/listinfo
>>>>
>>>
>>>
>>>
>>> --
>>> --
>>> James P. Kinney III
>>> Actively in pursuit of Life, Liberty and Happiness
>>>
>>> _______________________________________________
>>> Ale mailing list
>>> Ale at ale.org
>>> http://mail.ale.org/mailman/listinfo/ale
>>> See JOBS, ANNOUNCE and SCHOOLS lists at
>>> http://mail.ale.org/mailman/listinfo
>>>
>>
>>
>>
>> --
>> .!# RichardBronosky #!.
>>
>> _______________________________________________
>> Ale mailing list
>> Ale at ale.org
>> http://mail.ale.org/mailman/listinfo/ale
>> See JOBS, ANNOUNCE and SCHOOLS lists at
>> http://mail.ale.org/mailman/listinfo
>>
>
>
>
> --
> --
> James P. Kinney III
> Actively in pursuit of Life, Liberty and Happiness
>
--
--
James P. Kinney III
Actively in pursuit of Life, Liberty and Happiness
More information about the Ale
mailing list