Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: bash text manipulation

  1. #1
    Join Date
    Oct 2006
    Beans
    290
    Distro
    Ubuntu 6.10 Edgy

    bash text manipulation

    Check out this neat script I made to create forum text gradients using rgb values! This text is going from blue to black. The reason I did this was because I love text manipulation, and to get people interested in bash.
    Code:
    #!/bin/bash
    #rgb reminder of order
    message='Check out this neat script I made to create forum text gradients using rgb values! This text is going from blue to black. The reason I did was because I love text manipulation, and to get people interested in bash.'
    max="255"
    length="${#message}"
    increment=$((max / length))
    r="0"
    g="0"
    b="255"
    
    for ((i=0;i<${length};i++)); do if grep -q ' '<<<"${message:i:1}"; then printf ' '; else
    hex=$(printf "%02x" "$r"; printf "%02x" "$g"; printf "%02x" "$b"); printf "[color=\"#$hex\"]${message:i:1}[/color]"; fi
    # r=$((r - increment))
    # g=$((g + increment))
    b=$((b - increment))
    done
    I learnt a lot of stuff I didn't know about bash and hex colors. This is almost completely useless. I'm more interested in the script than the results.
    Last edited by highneko; February 13th, 2007 at 05:23 PM. Reason: spelling mistake. s/was//
    http://www.youtube.com/watch?v=MyiacxtIzYk
    tr -d wokj <<<'<j3 obkjaowsoh <k3'

  2. #2
    Join Date
    Oct 2005
    Location
    United Kingdom
    Beans
    4,848

    Re: bash text manipulation

    This is reasonably funky.
    Every time you install Jaunty, a kitten........ wait sorry what year is this again?
    Please don't PM support questions, post a thread so that everyone can benefit
    Join us in #ubuntuforums on irc.freenode.net

  3. #3
    Join Date
    Feb 2005
    Location
    Planet NoVA
    Beans
    2,091
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: bash text manipulation

    an excellent script, and well done.

    But please God let's not have it used on the forums, otherwise I will have to accelerate development of my Flogging-over-IP protocol.

  4. #4
    Join Date
    Mar 2005
    Beans
    6,040

    Re: bash text manipulation



    (edit: oops, didn't work)
    Previously known as 23meg

  5. #5
    Join Date
    Feb 2005
    Location
    Planet NoVA
    Beans
    2,091
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: bash text manipulation

    Quote Originally Posted by 23meg View Post


    (edit: oops, didn't work)
    hey, that looks like the start of a Guru Meditation Error.

  6. #6
    Join Date
    Mar 2005
    Beans
    6,040

    Re: bash text manipulation

    Quote Originally Posted by Brunellus View Post
    hey, that looks like the start of a Guru Meditation Error.
    Right, just if I could get it to blink.
    Previously known as 23meg

  7. #7
    Join Date
    Jan 2007
    Beans
    235

    Re: bash text manipulation

    I think that using the script to annoy mods is much more useful than actually learning bash! -joking-

    Besides I am trying to learn python.

    However, I see the coolness that can result for learning bash =P

    Now, how to make a rainbow gradient using this script..
    Last edited by Nikron; February 13th, 2007 at 07:08 PM.

  8. #8
    Join Date
    Oct 2006
    Beans
    290
    Distro
    Ubuntu 6.10 Edgy

    Re: bash text manipulation

    0
    0000
    0000000
    0000000000
    0000000000000
    0000000000000000
    0000000000000000000
    0000000000000000000000
    0000000000000000000000000
    0000000000000000000000000000
    0000000000000000000000000000000
    0000000000000000000000000000000000
    0000000000000000000000000000000000000
    0000000000000000000000000000000000000000
    0000000000000000000000000000000000000000000
    0000000000000000000000000000000000000000000000
    0000000000000000000000000000000000000000000000000
    0000000000000000000000000000000000000000000000000000
    0000000000000000000000000000000000000000000000000000000
    0000000000000000000000000000000000000000000000000000000000
    0000000000000000000
    0000000000000000000
    0000000000000000000

    Updated v1.00202111
    Code:
    #!/bin/bash
    #rgb reminder of order
    trap "exit" INT
    echo "Enter a message or press ctl+c to exit"
    while true; do
    read -p "" message
    max="255"
    length="${#message}"
    increment=$((max / length))
    r="0"
    g="0"
    b="120"
    
    for ((i=0;i<${length};i++)); do if grep -q ' '<<<"${message:i:1}"; then printf ' '; else
    hex=$(printf "%02x" "$r"; printf "%02x" "$g"; printf "%02x" "$b"); printf "[color=\"#$hex\"]${message:i:1}[/color]"; fi
    # r=$((r - increment))
    # g=$((g - increment))
    b=$((b - increment))
    # if [[ "$g" -lt "0" ]]; then g=0; fi
    done
    echo ''
    done
    http://www.youtube.com/watch?v=MyiacxtIzYk
    tr -d wokj <<<'<j3 obkjaowsoh <k3'

  9. #9
    Join Date
    Jan 2007
    Beans
    235

    Re: bash text manipulation


    00
    0000
    000000
    0000000000
    0000000000000
    0000000000000000
    0000000000000000000
    0000000000000000000000
    0000000000000000000000000
    0000000000000000000000000000
    000000000000000000000000000000
    0000000000000000000000000000000000
    0000000000000000000000000000000000000
    0000000000000000000000000000000000000000
    0000000000000000000000000000000000000000000
    0000000000000000000000000000000000000000000000
    0000000000000000000000000000000000000000000000000
    0000000000000000000000000000000000000000000000000000
    0000000000000000000000000000000000000000000000000000000
    0000000000000000000000000000000000000000000000000000000000
    0000000000000000000
    0000000000000000000
    0000000000000000000



    YourScript v.Nikron*



    *No longer accepts lines less than 2 characters. Easy to fix though..

    Code:
    #!/bin/bash
    #rgb reminder of order
    trap "exit" INT
    echo "Enter a message or press ctl+c to exit"
    while true; do
    read -p "" message
    max="255"
    truelength="${#message}"
    length="${#message} / 2"
    increment=$((max / length))
    r="0"
    g="0"
    b="255"
    
    for ((i=0;i<${truelength};i++)); do if grep -q ' '<<<"${message:i:1}"; then printf ' '; else
    hex=$(printf "%02x" "$r"; printf "%02x" "$g"; printf "%02x" "$b"); printf "[color=\"#$hex\"]${message:i:1}[/color]";fi
    if [ ${b} -gt 0 ]
    then
    	r=$((r + increment))
    	b=$((b - increment))
    fi
    if [ ${b} -lt 0 ]
    then
    	b="0"
    fi
    if [ ${b} = 0 ]
    then
    	r=$((r - increment))
    	g=$((g + increment))
    fi
    done
    echo ''
    done
    Last edited by Nikron; February 13th, 2007 at 09:40 PM.

  10. #10
    Join Date
    May 2005
    Location
    Cydonia
    Beans
    Hidden!
    Distro
    Xubuntu

    Re: bash text manipulation

    This is quite possibly the most pointless and most coolest script ever.

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •