Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Repeatative piping



Bash has the traditional C-style for-loop in addition to the classic
Bourne-style for-loop.

    for i in a b c d e f g ; do echo $i ; done

    for (( i=0 ; i < 10 ; i++ )) ; do echo $i ; done

So you could probably do something like

    FOO=$(g_u1 1 2 3 4)
    for (( i=0 ; i < 1000 ; i++ )) ; do
        FOO=$(echo $FOO | q_square)
    done
    echo $FOO



On Sun, Feb 22, 2009 at 12:11 PM, Doug <dougsweetser-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org> wrote:
> Hello:
>
> Just sitting around the house on a Sunday, trying to create the group
> U(1), a group involved with light.  I wrote a program that does one of
> the steps:
>
>> g_u1 1 2 3 4
> 0.1825741858350554 0.3651483716701107 0.5477225575051661 0.7302967433402214
>
> That is a normalized quaternion.  To make more members of the group,
> square the result:
>
>> g_u1 1 2 3 4 | q_square
> -0.933333 0.133333 0.200000 0.266667
>
> I'd like to do this a thousand times:
>
>> g_u1 1 2 3 4 | q_square | q_square | q_square ...
>
> There are lots of ways to do this.  One easy approach for me is write
> q_square_n, that given an n, does the loop.  I was curious if there
> was command line way to accomplish the same thing.  I don't know if I
> have used a for loop in a command line setting before.
>
> Doug
> _______________________________________________
> Discuss mailing list
> Discuss-mNDKBlG2WHs at public.gmane.org
> http://lists.blu.org/mailman/listinfo/discuss
>



-- 
John Abreau / Executive Director, Boston Linux & Unix
GnuPG KeyID: 0xD5C7B5D9 / Email: abreauj-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
GnuPG FP: 72 FB 39 4F 3C 3B D6 5B E0 C8 5A 6E F1 2C BE 99






BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org