On 27 May 2017 at 22:27, bruce <badoug...@gmail.com> wrote:
> Hi.
>
> I've got a file.. with a bunch of lines looking like:
>
>   $bookVariable['asu']['Fall-2016']='link';
>   $bookVariable['lehmancuny']['Fall-2016']='1';
>   $bookVariable['uvu']['Fall-2016']='1';
>   $bookVariable['wmich']['Summer II 2017']='1';
>   $bookVariable['wmich']['Summer I 2017']='1';
>   $bookVariable['dmacc']['Summer-2017']='1';
>   $bookVariable['sdmesa']['Summer-2017']='link';
>
> I''m looking to get the "text" inside the 1st group of brackets []
>
>
> The following sed only gets the 1st 3 lines.. and it doesn't completely work.
>
> sed -n "s/^.*bookVariable\['\(\S*\)'].*$/\1/p"  foo.txt
>
> asu']['Fall-2016
> lehmancuny']['Fall-2016
> uvu']['Fall-2016
>

Any reason why you can't just use cut?

cut -d"'" -f2 foo.txt

(-d is you singler quote delimiter - ' - surrounded by double quotes - " - )

If you want the quotes as well, then:

cut -d] -f1 foo.txt | cut -d[ -f2

-- 
Andy

The only person to have all his work done by Friday was Robinson Crusoe
_______________________________________________
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org

Reply via email to