Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Any easier way of parsing this file?



    Hi Bart :)

 * Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> dixit:
> On Oct 19, 12:53am, DervishD wrote:
> }
> }     The file contents are contained in a parameter (long story...),
> } and they MUST be contained in a parameter.
> } 
> }     Is there any better way of parsing this file using Zsh and
> } assuming that I may be interested in gathering the information for
> } other labels in the future?
> 
> Use IFS.  That's what it's for.
> 
> 	print -r $data | while IFS='=' read label content
> 	do
> 	    case $label in
> 	    SOMELABEL) : ... $content ... ;;
> 	    ANOTHERLABEL) : ... $content ... ;;
> 	    esac
> 	done

    Well, I was more interested in an alternative for the "print |
while read" but this is a good idea too. Less complex patterns.

    Thanks a lot, Bart :)

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736 | http://www.dervishd.net
http://www.pleyades.net & http://www.gotesdelluna.net
It's my PC and I'll cry if I want to...



Messages sorted by: Reverse Date, Date, Thread, Author