<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>bash &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://wordpress.com/tag/bash/</link>
	<description>Feed of posts on WordPress.com tagged "bash"</description>
	<pubDate>Wed, 21 May 2008 23:21:13 +0000</pubDate>

	<generator>http://wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[En vrac/bref - mardi 20 mai 2008]]></title>
<link>http://lokthare.wordpress.com/?p=26</link>
<pubDate>Tue, 20 May 2008 02:48:38 +0000</pubDate>
<dc:creator>lokthare</dc:creator>
<guid>http://lokthare.wordpress.com/?p=26</guid>
<description><![CDATA[Firefox et les liens irc / X-Chat
Firefox (v3 et précédentes) semble allergique aux liens irc chez]]></description>
<content:encoded><![CDATA[<h3>Firefox et les liens irc / X-Chat</h3>
<p>Firefox (v3 et précédentes) semble allergique aux liens irc chez moi. La modification de la page about:config ne fonctionne pas et le système introduit dans la version 3 n'apprécie pas l'ajout d'option.</p>
<p>Ma solution a été d'utiliser un petit script bash :</p>
<pre>#!/bin/bash
xchat -e --url=$1</pre>
<p>Il suffit de rendre le script exécutable puis de configurer Firefox pour qu'il l'utilise (irc dans l'onglet Applications)</p>
<h3>Expressions avec yum</h3>
<p>Je vois souvent sur les forums et les blogs des commandes du type :</p>
<pre>yum install -y gstreamer*</pre>
<p>où on utilise * pour installer plusieurs paquets en une seule commande. Au passage, cette méthode bien bourrin installera également les paquets de dévellopement et les paquets de debug (si le dépôt est activé).</p>
<p>En dehors de * (n'importe quels caractères), il y a également les accolades ({}) pour définir une liste, par exemple :</p>
<pre>yum install gstreamer-plugins-{ugly,schroedinger,farsight,bad,bad-extras}
yum install nautilus-{image-converter,open-terminal}</pre>
<p>On peut également définir des plages entre crochet. Exemple :</p>
<pre>yum list [a-zA-Z]im</pre>
<h3>xguest</h3>
<p>Tout vrai geek est parano (à un certain degré du moins), c'est pour cela qu'on ne laisse pas n'importe qui avoir accès n'importe comment à notre précieux ordinateur. Pour cela, il existe un paquet très pratique, <strong>xguest</strong>, qui crée un utilisateur nommé guest permettant à n'importe qui d'utiliser votre ordinateur entant qu'invité.</p>
<p>L'avantage de ce paquet par rapport à la création d'un utilisateur normal est que le guest est confiné grâce à SELinux (par exemple, guest ne peut pas utiliser su pour devenir root) et le home du guest est automatiquement nettoyer après déconnexion.</p>
<pre>yum install -y xguest</pre>
]]></content:encoded>
</item>
<item>
<title><![CDATA[tracks next action reminders in bash]]></title>
<link>http://aendruk.wordpress.com/?p=64</link>
<pubDate>Tue, 20 May 2008 01:36:55 +0000</pubDate>
<dc:creator>ændrük</dc:creator>
<guid>http://aendruk.wordpress.com/?p=64</guid>
<description><![CDATA[Chris over at the tracks.tra.in FAQ suggested using one of the Tracks plain text feeds as a message ]]></description>
<content:encoded><![CDATA[<p>Chris over at the <a href="http://ex.pla.in/tracks.tra.in">tracks.tra.in FAQ</a> suggested using one of the <a href="http://www.rousette.org.uk/projects/">Tracks</a> plain text feeds as a message of the day in <code>.bash_profile</code>. I open and close the terminal fairly frequently, so I thought it would be nice to save time and bandwidth by caching the text feed locally and downloading it again only if it's gotten too old.</p>
<p>I have the following line at the end of my <code>.bashrc</code>,<br />
[source language='python']# Tracks next action reminders<br />
~/bin/todo[/source]</p>
<p>and following script saved as <code>~/bin/todo</code>:<br />
[source language='python']#!/bin/bash</p>
<p># Plain text feed URL<br />
feed_url="https://tracks.tra.in/todos.txt?due=1&token=xxxxxxxxxxx-your-token-here-xxxxxxxxxxxx"</p>
<p># Where to save the list locally<br />
local_file="/home/user/.todo"</p>
<p># How many minutes old before downloading the latest todo list<br />
age_threshold=20</p>
<p># ------------------------------------------------------------------------------</p>
<p># Commandline arguments<br />
mode="$1"</p>
<p># Check for and create local_file<br />
if [ ! -f $local_file ]; then<br />
	touch $local_file<br />
	mode="update"<br />
fi</p>
<p># Calculate how old the current todo list is<br />
age_in_minutes=$(echo "(`date +%s` - `date -r $local_file +%s`) / 60" &#124; bc)</p>
<p># If it's been too long since the todo list was last updated,<br />
if [ $age_in_minutes -gt $age_threshold ] &#124;&#124; [ "$mode" = "update" ]; then</p>
<p>	# Download the latest todo list<br />
	echo -n "${age_in_minutes} minutes since last update. Getting todo list... "<br />
	wget -q --timeout=4 -O $local_file $feed_url && echo "`color green`OK`color off`" &#124;&#124; echo "`color red`Failed`color off`"</p>
<p>else</p>
<p>	# Otherwise, just use the one we already have<br />
	echo "Updated ${age_in_minutes} minutes ago."</p>
<p>fi</p>
<p># Print out the list<br />
color ltblue && cat $local_file && color off[/source]</p>
<p>To force an update, <code style="color:green;">$ ~/bin/todo update</code>.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Another Link to EBooks...]]></title>
<link>http://gayhacker.wordpress.com/?p=73</link>
<pubDate>Sun, 18 May 2008 03:29:15 +0000</pubDate>
<dc:creator>Hexadecimal</dc:creator>
<guid>http://gayhacker.wordpress.com/?p=73</guid>
<description><![CDATA[This site has a lot of books that you should only download if you physically own, Mr. Pirate  
http:]]></description>
<content:encoded><![CDATA[<p>This site has a lot of books that you should only download if you physically own, Mr. Pirate ;)</p>
<p><a href="http://wifi.ham-radio-op.net/misc/compsci/">http://wifi.ham-radio-op.net/misc/compsci/</a></p>
<p>For those of you who don't know, ham-radio-op.net is run by <a href="http://www.dyndns.com/">dyndns.com</a>, which probably means that the person running "wifi" has his own server.  See the dyndns website if you have no clue what I'm talking about.</p>
<p>Updating my <a href="http://gayhacker.wordpress.com/2008/05/12/e-books-about-hacking/">EBooks</a> post...</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[ls]]></title>
<link>http://doubledot.wordpress.com/?p=3</link>
<pubDate>Sat, 17 May 2008 20:26:40 +0000</pubDate>
<dc:creator>gregorybarborini</dc:creator>
<guid>http://doubledot.wordpress.com/?p=3</guid>
<description><![CDATA[list the content of a directory
]]></description>
<content:encoded><![CDATA[<p>list the content of a directory</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Diagrama - Historia de los Lenguajes de Programacion]]></title>
<link>http://julianrdz.wordpress.com/?p=31</link>
<pubDate>Sat, 17 May 2008 02:01:35 +0000</pubDate>
<dc:creator>Julián Rodríguez</dc:creator>
<guid>http://julianrdz.wordpress.com/?p=31</guid>
<description><![CDATA[
Aqui les dejo este diagrama creado por Éric Lévénez, en el cual mediante informacion logro plasm]]></description>
<content:encoded><![CDATA[<p style="text-align:center;"><img class="aligncenter" src="http://julianrdz.wordpress.com/files/2008/05/code_human.gif" alt="" width="200" height="283" /></p>
<p>Aqui les dejo este diagrama creado por Éric Lévénez, en el cual mediante informacion logro plasmar la historia de los lenguajes de programacion detalladamente y muy claro.</p>
<p style="text-align:center;"><a href="http://www.oreilly.com/news/graphics/prog_lang_poster.pdf">Download PDF</a></p>
<p style="text-align:center;"><a href="http://www.oreilly.com/pub/a/oreilly/news/languageposter_0504.html">Mas Informacion</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[NoPaste over shell with &quot;sprunge&quot;]]></title>
<link>http://mattelacchiato.wordpress.com/2008/05/16/nopaste-over-shell-with-sprunge/</link>
<pubDate>Fri, 16 May 2008 13:01:00 +0000</pubDate>
<dc:creator>mattelacchiato</dc:creator>
<guid>http://mattelacchiato.wordpress.com/2008/05/16/nopaste-over-shell-with-sprunge/</guid>
<description><![CDATA[With sprunge.us you can pipe an output of a shellapplication to its nopaste-webservice. It returns t]]></description>
<content:encoded><![CDATA[<p>With <a href="http://sprunge.us/">sprunge.us</a> you can pipe an output of a shellapplication to its nopaste-webservice. It returns the URL of the pasting at sprunge.<br />
Look at the homepage to see its manpage!</p>
<p>My rating: 4 of 5 Nerds =)</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[give me a shell]]></title>
<link>http://netcrash.wordpress.com/?p=100</link>
<pubDate>Fri, 16 May 2008 02:46:12 +0000</pubDate>
<dc:creator>Fernando André</dc:creator>
<guid>http://netcrash.wordpress.com/?p=100</guid>
<description><![CDATA[ls -l  | awk &#8216;{ system(&#8221;chown -R &#8220;$3&#8243; &#8220;$  }&#8217;
//cuidado com dire]]></description>
<content:encoded><![CDATA[<p>ls -l  &#124; awk '{ system("chown -R "$3" "$8) }'</p>
<p>//cuidado com directorios que contenham espaços doens't work with spaces ;</p>
<p>find /home/ -uid 0 -exec ls -l \{\} \;</p>
<p>fgrep 'gold' /var/log/ -R &#124; grep -i something</p>
<p>or regexp style search<br />
egrep '(err&#124;fail&#124;warning)' /var/log/* &#62; `date +%F`.txt</p>
<p>ls -l  &#124; sed -e 's/andre/netcrash/gi'</p>
<p>#!/usr/bin/perl</p>
<p>print "hello\n";<br />
$dir="/home/andre";<br />
if ( (!(-d $dir."/Maildir")) ){<br />
`/usr/bin/maildirmake.maildrop $dir"/Maildir"`;</p>
<p>}</p>
<p>bash<br />
[03:42:08]andre@garden:~$ for i in `seq 10`; do echo $i ; done;</p>
<p>Haven't been using cut that mutch but, also a good weapon of choice.</p>
<p><strong>Simple things that evolve to more complex tools :D</strong></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[NapiProject (linux) - skrypt rekurencyjny]]></title>
<link>http://spassite.wordpress.com/?p=13</link>
<pubDate>Thu, 15 May 2008 21:49:41 +0000</pubDate>
<dc:creator>spassite</dc:creator>
<guid>http://spassite.wordpress.com/?p=13</guid>
<description><![CDATA[
Motywacja
Alternatywą dla znanego wszystkim programu NapiProject pod linuksa (poza odpalaniem Napi]]></description>
<content:encoded><![CDATA[<p style="text-align:center;"><img class="aligncenter" src="http://upload.wikimedia.org/wikipedia/commons/thumb/d/d8/Tux-linux_logo.svg/280px-Tux-linux_logo.svg.png" alt="Linux inside ;)" width="122" height="130" /></p>
<p><span style="text-decoration:underline;"><strong>Motywacja</strong></span></p>
<p>Alternatywą dla znanego wszystkim programu NapiProject pod linuksa (poza odpalaniem Napi przez Wine) jest programik napisany w pythonie autorstwa panów(tak mniemam): gim,krzynio,dosiu,hash.<br />
Programik mimo, iż działa wzorowo nie ma opcji przeszukiwania rekurencyjnego katalogów, czyli w uproszczeniu: podaj_katalog -&#62; znajdź_filmy -&#62; znajdź_do_nich_napisy. W takim właśnie uproszczeniu i bez fajerwerków (sprawdzania np. czy katalog istnieje etc) działa poniższy skrypcik.</p>
<p><span style="text-decoration:underline;"><strong>Skrypt wygląda następująco:</strong></span></p>
<blockquote><p><em>#!/bin/bash<br />
#---------------------------------------#<br />
#skrypt by spas (spassite.wordpress.com)#<br />
#---------------------------------------#<br />
dir="/katalog/z/filmami/"<br />
ext=".avi"; #rozszerzenie do wyszukania<br />
find $dir -name "*.avi" &#124; while read file<br />
do<br />
name=`echo $file &#124; sed 's/.avi//'`; #utnij rozszerzenie<br />
file=`echo $file &#124; sed 's/ /\ /'`;<br />
if [ ! -e "${name}.txt" ]; then #czy napis jeszcze niepobrany?<br />
echo "${name}.avi"<br />
./napi.py "$file"; #wywolaj skrypt dla filmów bez napisów<br />
fi<br />
done</em></p></blockquote>
<p><span style="text-decoration:underline;"><strong>Aby uruchomić skrypt:</strong></span></p>
<blockquote><p><em>chmod +x plik_z_powyższym_skryptem.sh<br />
./plik_z_powyższym_skryptem.sh</em></p></blockquote>
<p>Do jego działania niezbędny jest napi.py w tym samym katalogu co skrypt, oraz paczka "p7zip-full" (sudo aptitude install p7zip-full), bez której napi.py nie będzie poprawnie pobierać napisów.</p>
<p><span style="text-decoration:underline;"><strong>Lista życzeń (czyt. co zrobię jak będę miał chwilkę):</strong></span></p>
<ul>
<li>sprawdzanie, czy katalog istnieje</li>
<li>ścieżka do katalogu odczytywana ze zmiennych wywołania</li>
<li>obsługa wielu rozszerzeń</li>
<li>...</li>
</ul>
<p><strong><span style="text-decoration:underline;">Pliki do pobrania:</span></strong></p>
<p><span class="a"><a title="Napi.py" href="http://napi.py.googlepages.com/napi.py" target="_blank">napi.py</a> - program ściągający napisy do pobrania</span></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[The Eagle's]]></title>
<link>http://ipictureyouandme.wordpress.com/?p=15</link>
<pubDate>Thu, 15 May 2008 05:38:44 +0000</pubDate>
<dc:creator>ipictureyouandme</dc:creator>
<guid>http://ipictureyouandme.wordpress.com/?p=15</guid>
<description><![CDATA[Ok, now I have the attention, of:
1. Football Fans
2. Music Junkies
3. Bird Lovers
4. Eagle&#8217;s ]]></description>
<content:encoded><![CDATA[<p>Ok, now I have the attention, of:</p>
<p>1. Football Fans<br />
2. Music Junkies<br />
3. Bird Lovers<br />
4. Eagle's Nest Members/attendees </p>
<p>Ok, well sorry to disappoint any of the people in categories 1-3, but I'm not talking about Football, Music, or Birds. THESE THOUGHTS CAME TO ME WHILE CLEANING... <strong><em>Fi</em></strong><strong><em>rst, I want to put out a disclaimer, that this specific blog post is not a bash on anyone, it is not written out of anger, and it is not intended for the purposes of de-facing the value of the history of Eagle's Nest.</em></strong>  </p>
<p>A little back story for my new/outside readers. I attend, and have attended Eagle's Nest Fellowship Church for a little under 11 years now, Have been very involved with many ministries and have even worked for the church some as well. Now there is a point to all of this and if you leave now you'll probably just think I'm another agree rebellious teenager (19)...but this blog is going to be pretty honest only for the sake of making a good point.</p>
<p>I'm afraid that it won't do the story justice, but I have to start somewhere, so i'll start with the fact that Eagle's Nest has many Eagle's and paintings of eagle's and are logo has an eagle on it...and rightfully so I might add, goes well with the name...  and so throughout the building you will find many. *(I think in one office I have counted somewhere around 20) Now, of-course some of us love to joke about it, and the truth is that Eagle's happen to be a large part of who we are. </p>
<p>**So, I have a confession to make. I have been on a team (comprised of myself only) responsible for the slow removal of Eagle's from the viewable presence of people. Yes, this is true i started stashing them. Only I soon realized that soon there would be no decorations left, so I gave up. but if you read this and your favorite piece is missing, come find me on Sunday, I'll give it to you and you can take it home with you.**</p>
<p>I share this next true story from my perspective, and my perspective only. And I'm not using names for the sake of... well you get the picture. But one sunday, After the removal of a particular Eagle Painting I, along with a few other people where questioned about the disappearance of said eagle, (said eagle had been promptly replaced by a beautiful hand painting from another location.) If I believe correctly, we lied, and said we didn't know where it was and for that I am sorry. However, by the next week the Eagle was placed back and has remained there since. Apparently other church members had complained or otherwise asked about the painting not being there.</p>
<p><strong>IF I'M LOOSING YOU</strong>... hang in there I'm getting to my point.</p>
<p>Wake up church, that is my message. That is my challenge to you!!!! Some people may argue and say that I'm just as wrong for wanting the Eagle to not be there. but<strong> I'm not saying that</strong>. I'm saying that Its <strong>NOT</strong> about what is hanging on our walls.<strong> AND WE HAVE MADE IT ABOUT THAT</strong>.  If we don't love people like we should then the stuff on our walls is <strong>POINTLESS</strong>. </p>
<p>Community is not about some identity, (ours being the eagle) Its about fellowship. Where are all the pictures of ministry happening, and the art work of worshipers, where is the life and the joy that we are sharing?? Why don't we publish that to our people? why not leave our corporate Identity for the sake of our community?</p>
<p>This will be my final paragraph I promise I have written enough, and feel like i have explained nothing, but hopefully your hearing my heart here. Ok, so I'm going to leave you with these last thoughts. I go to college, and I spend time with people who are hurting, and seeking and <strong>NOT FINDING A PLACE.</strong> Where do these young people hang out? a lot of them, bars. what if our church looked like a bar? Ok, <strong>HEAR ME</strong> I'm not suggesting that we rip out everything and start serving beer. But I am asking you to consider <strong>WHAT ARE WE ABOUT?</strong> <strong>are we about our pictures of eagles? Are we about our favorite songs? are we about pretty colors? are we about fancy buildings or Amazing Graphics? OR are we about showing people the LIFE found in jesus?</strong> What if we stopped going to church on sunday for ourselves and started going for everyone else? Why wouldn't the church be the perfect place to display EVERYTHING going on in the community of the church itself?  And so I leave you with this question, and this challenge.</p>
<p>Ask yourself this question: WHAT IF CHURCH WAS BUILT FOR THEM AND NOT FOR ME.</p>
<p>thanks for enduring, if you have questions or you'd like to beat me up for my honesty please email me: takaminescx@gmail.com. I hope that you have heard my heart I strive to love you all with everything I have. And I want to be a piece of building something so much greater then anyone of us could be alone. <br />
In Christ's Service<br />
Jeffery Peck</p>
<p>(www.myspace.com/no_your_other_left) </p>
<p><strong>*** if you email me comments, I may in-fact post them back on here to reply.***</strong></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Scripting with ANSI Color Codes]]></title>
<link>http://brianin3d.wordpress.com/?p=4</link>
<pubDate>Wed, 14 May 2008 16:36:43 +0000</pubDate>
<dc:creator>brianin3d</dc:creator>
<guid>http://brianin3d.wordpress.com/?p=4</guid>
<description><![CDATA[Oh the console! Love it or loath it, if you engage in computer actions you probably end up spending ]]></description>
<content:encoded><![CDATA[<p>Oh the console! Love it or loath it, if you engage in computer actions you probably end up spending a lot of time looking at a console.</p>
<p>Of course not all consoles are created equal. Some consoles are really just the equivalent of</p>
<p>while line=nextLine() ; do print line ; end</p>
<p>Typically this is reserved to crappy IDE's (yes, I know that's redundant, I'm making a hah-hah).</p>
<p>Some deluded souls think cygwin is a real console, only to discover half-way into trying to actually get something done that it ends up going nutso and spewing text in the most unlikely of locations. Infrequently this can lead to a series of awkward questions in the ER.</p>
<p>Gnome's terminal is pretty adequate, and of course you can't go wrong with xterm or a host of other well written, robust terminals that oddly enuff seem to show up only under flavors of UNIX (yes, netBSD... err.. Mac counts too).</p>
<p>Why is writing a solid console implementation so difficult? </p>
<p>Because a console is not about printing lines of text. A terminal is more like a pixel-based display where ever pixel is a character + presentation information. </p>
<p>It is a highly sophisticated user interface. Unlike the farktarded point-and-click UI's popular today for no good reason which use a maximum of say 8 buttons, a console typically has 108+ buttons.</p>
<p>Hah-hah, indeed. More importantly a console is really an interpreter. </p>
<p>No, I don't mean the shell, I mean the console is an interpreter. Just like with shells we have bash, tcsh and crapsh, terminals come in flavors like VT100, VT110, VT220, 3270, 5270 and plethora of others.</p>
<p>Since a terminals has to accept all sorts of input, the language for controlling the terminal is a done via "control codes." Typically a control code is just a string which is difficult to type.</p>
<p>For example: echo &#60;ESC&#62;[33mCheese&#60;ESC&#62;[0m</p>
<p>What is that &#60;ESC&#62;? Typically it is character 27. How do you type it? On a lot of consoles, you type it like this:</p>
<ol>
<li>hold down the control key</li>
<li>press the 'v' key</li>
<li>let go of the control and 'v' key</li>
<li>press the escape key</li>
</ol>
<p>Pretty neat, huh? That works for ANSI/VT100-based terminals. Not for all terminals. Luckily for us, that's just about all we really care about.</p>
<p>Of course a real console application (eg: vim) cares about all terminals and you start to move away from writing control codes directly and towards using terminal apis like curses/ncurses PDQ.</p>
<p>For hacking purposes, VT100 terminal codes will do just fine.</p>
<p>I know.. what a load of historic irrelevant blather and so what and quit wasting my time! What is it good for?!</p>
<p>When was the last time you looked at a log file? Let me put it a different way, when did you stop looking at log files? Chances are you are watching a log file right now! I know I am!</p>
<p>What percentage of log output do you care about for a given task? 10%? 2%? Isn't it a drag that it just blends in with the rest?</p>
<p>Of course you could grep it out, but then you lose the context... Or you might forget a term and have to reproduce the problem again (again [again]).</p>
<p>IMHO, a kick-aspirin use for VT100 color codes is for log highlighting, and it is some simple, it can be easily scripting into a general use script.</p>
<p>Here is the kind of usage I would like:</p>
<pre>
usage: cat foo &#124; line_lite.sh ( pattern highlighting )+

pattern         is a ala grep
highlighting    is a colon separated list of colors

the colors are 

    reset        bright      dim         underline    blink
    reverse      hidden      black       red          green
    yellow       blue        magenta     cyan         white
    black_bg     red_bg      green_bg    yellow_bg    blue_bg
    magenta_bg   cyan_bg     white_bg
</pre>
<p>That way I can use it like: tail -f some.log &#124; line_lite.sh Exception red "some other text" green:underline</p>
<p>In order to make this happen, I need to convert that red, green:underline crap to the appropriate VT100 code.</p>
<p>Natually, I do this with sed:</p>
<pre>
_line_lite_color_to_code() {
    echo ${*} &#124; sed "s,reset,0,g;s,bright,1,g;s,dim,2,g;s,underline,4,g;s,blink,5,g;s,reverse,7,g;s,hidden,8,g;s,black,30,g;s,red,31,g;s,green,32,g;s,yellow,33,g;s,blue,34,g;s,magenta,35,g;s,cyan,36,g;s,white,37,g;s,black_bg,40,g;s,red_bg,41,g;s,green_bg,42,g;s,yellow_bg,43,g;s,blue_bg,44,g;s,magenta_bg,45,g;s,cyan_bg,46,g;s,white_bg,47,g;s,:,;,g"
}

_line_lite_code() {
    _line_lite_color_to_code ${*} &#124; sed 's,.*,ESC[&#38;m,'
}
</pre>
<p>This will convert "green:underline" to [32;4m</p>
<p>Now we just need some way to do our matching and add the color code. Once again, it's sed time. </p>
<p>For each pair of pattern/color, we create a sed expression like: s!.*.*!<code>&#38;!g; </p>
<p>In this case we'd have s!.*some other text.*![32;4m&#38;[0m!g;</p>
<p>All that we have to do is concatenate our sed expressions for each pattern/color pair and then call sed.</p>
<p>Viola! Arbitrarily colored logs! </p>
<p>Here is sample output from something that's not a log:</p>
<pre>
% jar_minder_javap sun.security.provider.PolicyFile &#124; line_lite.sh 'static'  red:bright
Compiled from "PolicyFile.java"
public class sun.security.provider.PolicyFile extends java.security.Policy{
    public sun.security.provider.PolicyFile();
    public sun.security.provider.PolicyFile(boolean);
    public void refresh();
    public boolean implies(java.security.ProtectionDomain, java.security.Permission);
    public java.security.PermissionCollection getPermissions(java.security.ProtectionDomain);
    public java.security.PermissionCollection getPermissions(java.security.CodeSource);
    protected java.security.cert.Certificate[] getSignerCertificates(java.security.CodeSource);
</font><font color="red"></font><b>    static boolean access$002(sun.security.provider.PolicyFile, boolean);</font></font></u></b></i>
</font><font color="red"></font><b>    static boolean access$102(sun.security.provider.PolicyFile, boolean);</font></font></u></b></i>
</font><font color="red"></font><b>    static boolean access$202(sun.security.provider.PolicyFile, boolean);</font></font></u></b></i>
</font><font color="red"></font><b>    static boolean access$302(sun.security.provider.PolicyFile, boolean);</font></font></u></b></i>
</font><font color="red"></font><b>    static boolean access$200(sun.security.provider.PolicyFile);</font></font></u></b></i>
</font><font color="red"></font><b>    static sun.security.util.Debug access$400();</font></font></u></b></i>
</font><font color="red"></font><b>    static boolean access$500(sun.security.provider.PolicyFile, java.net.URL, sun.security.provider.PolicyInfo);</font></font></u></b></i>
</font><font color="red"></font><b>    static java.security.CodeSource access$600(sun.security.provider.PolicyFile, java.security.CodeSource, boolean);</font></font></u></b></i>
</font><font color="red"></font><b>    static java.lang.String access$700(sun.security.provider.PolicyFile, java.security.ProtectionDomain);</font></font></u></b></i>
</font><font color="red"></font><b>    static java.security.IdentityScope access$800();</font></font></u></b></i>
</font><font color="red"></font><b>    static {};</font></font></u></b></i>
}
</pre>
<p>Sadly, my olde ascii2html script is not quite it... but I think you get the idea.</p>
<p>Go forth and dig them control codes, my friend! They exist only to serve your dread will.</p>
<p>Since this post is already longer than the list of man's sin, here is the listing for line_lite.sh</p>
<hr />
<hr />
<pre>
_line_lite_usage() {
cat &#60;&#60; EOM

usage: cat foo &#124; line_lite.sh ( pattern highlighting )+

pattern         is a ala grep
highlighting    is a colon separated list of colors

the colors are 

    reset        bright      dim         underline    blink
    reverse      hidden      black       red          green
    yellow       blue        magenta     cyan         white
    black_bg     red_bg      green_bg    yellow_bg    blue_bg
    magenta_bg   cyan_bg     white_bg    

EOM
}

_line_lite_color_to_code() {
        echo ${*} &#124; sed "s,reset,0,g;s,bright,1,g;s,dim,2,g;s,underline,4,g;s,blink,5,g;s,reverse,7,g;s,hidden,8,g;s,black,30,g;s,red,31,g;s,green,32,g;s,yellow,33,g;s,blue,34,g;s,magenta,35,g;s,cyan,36,g;s,white,37,g;s,black_bg,40,g;s,red_bg,41,g;s,green_bg,42,g;s,yellow_bg,43,g;s,blue_bg,44,g;s,magenta_bg,45,g;s,cyan_bg,46,g;s,white_bg,47,g;s,:,;,g"
}

_line_lite_code() {
        _line_lite_color_to_code ${*} &#124; sed 's,.*,ESC[&#38;m,'
}

_line_lite_expr() {
        local pattern="${1}"
        local lite=$( _line_lite_code ${2})
        echo "s!.*${pattern}.*!${lite}&#38;ESC[0m!g;"
}

_line_lite_it_up() {
        local expression=${1}
        if [ "" == "${expression}" ] ; then
                _line_lite_usage
        else
                sed "${expression}"
        fi
}

#####################
# normally I would put this in a function, but it hoses up the args

_line_lite_it_up_expression=""
while [ 2 -le ${#} ] ; do
        _line_lite_it_up_expression="${_line_lite_it_up_expression}$( _line_lite_expr "${1}" "${2}" )"
        shift 2
done

_line_lite_it_up "${_line_lite_it_up_expression}"
</pre>
<hr />
<hr />
<p>Dude has had this great link for a jillion years! <a title="ANSI/VT100 Terminal Control" href="http://www.fh-jena.de/~gmueller/Kurs_halle/esc_vt100.html">http://www.fh-jena.de/~gmueller/Kurs_halle/esc_vt100.html</a>, what a hero!</p>
<p>P.S.: Yes, I advocate EMACS-hateration. set -o vi or fight!</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[jEdit pod Ubuntu]]></title>
<link>http://masterixzone.wordpress.com/?p=126</link>
<pubDate>Tue, 13 May 2008 18:20:07 +0000</pubDate>
<dc:creator>masterix</dc:creator>
<guid>http://masterixzone.wordpress.com/?p=126</guid>
<description><![CDATA[jEdit w wersji na systemy uniksowe ma instalkę w postaci pliku .jar. Po instalacji również nie tw]]></description>
<content:encoded><![CDATA[<p>jEdit w wersji na systemy uniksowe ma instalkę w postaci pliku .jar. Po instalacji również nie tworzę się żadne skróty, ikony ani pozycje w menu jak to ma miejsce w przypadku Windowsa. Dlatego krótki tutorial, jak ułatwić sobie życie.</p>
<p>Otwórz dowolny edytor tekstowy( np gEdit, Kate, vi etc ) i wpisz w nim taki kod:</p>
<blockquote><p>#!/bin/bash<br />
java -jar ../jedit/4.2/jedit.jar</p></blockquote>
<p>Zapisz plik jako jedit.sh ( lub jakkolwiek chcesz inaczej, tylko trzymaj się konsekwentnie tego ). Ja to zrobiłem na pulpicie, żeby mieć go pod ręką zawsze. W konsoli nadaj odpowiednie uprawienia dla tego pliku poprzez komendę chmod, np tak:</p>
<blockquote><p>chmod 0777 jedit.sh</p></blockquote>
<p>Oczywiście musisz być w tym samym katalogu.</p>
<p>Teraz dwuklik na pliku jedit.sh na pulpicie spowoduje wyświetlenie monitu z pytanie co zrobić, wystarczy wybrać "Uruchom" i działa.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[IRC client scritto in 40 righe di bash script :)]]></title>
<link>http://fox91.wordpress.com/?p=126</link>
<pubDate>Tue, 13 May 2008 13:39:10 +0000</pubDate>
<dc:creator>fox1991</dc:creator>
<guid>http://fox91.wordpress.com/?p=126</guid>
<description><![CDATA[Devo dire che quando ho visto questo link sono rimasto di stucco&#8230;
Non pensavo esistesse gente ]]></description>
<content:encoded><![CDATA[<p>Devo dire che quando ho visto <a href="http://lists.canonical.org/pipermail/kragen-hacks/2008-February/000480.html">questo link </a>sono rimasto di stucco...<br />
Non pensavo esistesse gente tanto malata che in mancanza d'altro si mettano a programmare un IRC client durante il netinst di debian. E il tutto solo perchè Kragen era stufo di stare con le mani in mano e con una grande voglia di chattare. Che dire...un genio!</p>
<p>
<em>So I'm installing an OS on my laptop, and for whatever reason, the<br />
Debian Etch install disk thought it would be a good idea to initialize<br />
the whole disk to random data *before* rather than *after* the rest of<br />
the install.  Writing to the whole disk takes a long time --- a few hours ---<br />
and so I'm left with the Debian netinst environment to play with.</p>
<p>So I decided to IRC.  Unfortunately, the only programming language I could<br />
find is sh, and there don't seem to be any IRC clients.  And I can't get<br />
the ssh client to work --- I was able to install the ssh client from the<br />
udeb on the CD-ROM with udpkg -i path/to/openssl-client-whatever.udeb.  But<br />
it depends on libnsl.so.1, and I don't know what udeb I have to install to<br />
get that.</p>
<p>So I wrote my own IRC client in shell.  The output is a little ugly, and<br />
there's no line editing or multiple window support, but otherwise it's just<br />
like any other IRC client to use.  Almost.</em></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Bitwise operations]]></title>
<link>http://selmys.wordpress.com/?p=4</link>
<pubDate>Mon, 12 May 2008 12:15:16 +0000</pubDate>
<dc:creator>selmys</dc:creator>
<guid>http://selmys.wordpress.com/?p=4</guid>
<description><![CDATA[Finally, I&#8217;ve found something that can&#8217;t easily be done in BASH. I&#8217;m speaking abou]]></description>
<content:encoded><![CDATA[<p>Finally, I've found something that can't easily be done in BASH. I'm speaking about bitwise operations. Yes, BASH supports bitwise operators like negate (~), and (&#38;), or (&#124;), xor (^) and left and right shift (&#60;&#60; &#62;&#62;). The problem is that these operators only work on signed integers. That means if you negate 3, for example, you end up with -4 because the signed bit gets toggled as well. I suppose we could multiply the result by -1 to get a better answer but that's more work and seems like a kludge. And what about very large numbers that are beyond the range of a 4 or 8 byte integer? Well, we could use bc, but bc has no bitwise operators.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Problema con función busqueda de HuaweY!]]></title>
<link>http://facusdelacruz.wordpress.com/?p=129</link>
<pubDate>Mon, 12 May 2008 11:23:13 +0000</pubDate>
<dc:creator>Overclock_Orange</dc:creator>
<guid>http://facusdelacruz.wordpress.com/?p=129</guid>
<description><![CDATA[La estructura creo que esta bién. ¿Ustedes que opinan? ¿Donde estan los errores?
Sugerencias: fmd]]></description>
<content:encoded><![CDATA[<p>La estructura creo que esta bién. ¿Ustedes que opinan? ¿Donde estan los errores?<br />
<span style="text-decoration:underline;">Sugerencias:</span> <em>fmdlc.unix [--en--] gmail dot com</em></p>
<ol>
<li>El script busca automaticamente el software usando los comandos<br />
locate $ARCHIVO &#124; grep .tar.gz<br />
donde $ARCHIVO contiene el nombre aproximado a buscar (*uagle*)</li>
<li>Si no lo encuentra informa al usuario que realizara una busqueda<br />
intensiva en / utilizando find / -name *archivo*</li>
<li>Si no lo encuentra le pide al usuario que introdusca un path al archivo.<br />
Si la ruta no es valida hace un bucle a la misma función.<br />
Si lo encuentra pasa a la función instala.</li>
</ol>
<p><strong>NOTA:</strong> Igual hay que trabajar mucho mas esta función</p>
<blockquote><p><code> #### BEGIN ####</code></p>
<p>#!/bin/bash</p>
<p>#Función path_1<br />
function path_1 {<br />
echo -n "Path no valido. Ingrese path valido"; read FILE_1<br />
while_1<br />
}</p>
<p>#Función while_1<br />
function while_1 {<br />
while [ -f $FILE_1 ]; path_1<br />
do<br />
echo "Path localizado";  instala #llama a la función Instala<br />
done<br />
}</p>
<p>#Function find_1<br />
function find_1 {</p>
<p>SEARCH_FIND_1=$(find $HOME/Otros -name $FIRMWARE)</p>
<p>#Evaluacion de condicion<br />
if [ $? -gt 1 ]; then<br />
echo "Path valido, la instalación puede proseguir"<br />
instala #llama a la función instala<br />
else<br />
read -p "Archivo no encontrado, introduzca una ruta valida hacia el firmware:" FILE<br />
if [ ! -z $FILE ]; then<br />
echo "Path valido"<br />
instala #llama a la función instala<br />
else<br />
echo "No introducio niguna ruta valida, introduzca el path al firmware"<br />
path_1 #Llama a la función path_1<br />
fi<br />
fi<br />
}</p>
<p>#Define variables de busqueda<br />
FIRMWARE="*ueagle*"<br />
locate $FIRMWARE &#124; grep .tar.gz</p>
<p>#Evaluación de condiciones<br />
if [ $? -gt 0 ]; then echo "Archivo no encontrado" &#38;&#38; find_1<br />
else<br />
echo "Archivo encontrado" &#38;&#38; instala #llama a la función instalar<br />
fi</p>
<p>exit 0</p>
<p>#### END ####</p></blockquote>
]]></content:encoded>
</item>
<item>
<title><![CDATA[bash/python - extracting links from an html file]]></title>
<link>http://knubbl.wordpress.com/?p=4</link>
<pubDate>Sun, 11 May 2008 20:29:12 +0000</pubDate>
<dc:creator>knubbl</dc:creator>
<guid>http://knubbl.wordpress.com/?p=4</guid>
<description><![CDATA[I recently came across the need to extract links from an html file. Of course I wanted to automate t]]></description>
<content:encoded><![CDATA[<p>I recently came across the need to extract links from an html file. Of course I wanted to automate the whole procedure. There is an easy way of doing this using the bash shell.<br />
<code><br />
cat  file &#124; grep "=href" &#124; cut -d"/" -f3<br />
</code><br />
This gives you some ugly links so you can improve it by grepping the domain name.<br />
<code><br />
cat file &#124; grep "=href" &#124; cut -d"/" -f3 &#124; grep domain<br />
</code><br />
Of course domain is the domain name which should be included in the links.</p>
<p>Since I still wasn't satisfied I wrote a little program in python which does exactly the same thing as the commands mentioned above. Here is the code:</p>
<p>#!/usr/bin/env python</p>
<p>import sys</p>
<p>def usage():</p>
<ul>
print "usage: %s " % sys.argv[0]<br />
print "prints all the links contained in that file"
</ul>
<p>def extractLink(line, tag):</p>
<ul>
index = line.find(tag)+len(tag)+1<br />
end = line.find("\"", index+1)<br />
link = line[index:end]<br />
return link
</ul>
<p>if len(sys.argv) &#60; 2:</p>
<ul>
usage()<br />
sys.exit()
</ul>
<p>file = sys.argv[1]<br />
text = open(file, "r").readlines()<br />
linklist = []<br />
tag = "href="<br />
for line in text:</p>
<ul>
if tag in line:</p>
<ul>
link = extractLink(line, tag)<br />
if not "\"" in link and not "'" in link:</p>
<ul>
print link
</ul>
</ul>
</ul>
<p>This seems to be a lot of code but it actually isn't considering that it was written in a higher level language. <strong>If you want to use this code you have to align it properly.</strong></p>
<p>Feel free to post some improvements.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Bash Scripting: Mp3 Renaming]]></title>
<link>http://squirreling.wordpress.com/?p=50</link>
<pubDate>Sun, 11 May 2008 17:18:19 +0000</pubDate>
<dc:creator>squirreling</dc:creator>
<guid>http://squirreling.wordpress.com/?p=50</guid>
<description><![CDATA[Just wrote a quick script to rename a bunch of mp3 files, removing the site name from the file.  (i]]></description>
<content:encoded><![CDATA[<p>Just wrote a quick script to rename a bunch of mp3 files, removing the site name from the file.  (ie from "<strong>23 Glory [www.site.com].mp3</strong>" to "<strong>23 Glory.mp3</strong>".  This uses the <strong>${var%remove-from-end}</strong> bash variable manipulation.</p>
<blockquote><p><code>for file in *.mp3<br />
do<br />
</code>&#160; &#160;&#160; &#160;<code> mv "$file" "${file%\[www.site.com\].mp3}.mp3"<br />
done</code></p></blockquote>
<p>See the <a href="http://www.tldp.org/LDP/abs/html/string-manipulation.html">Advanced Variable Manipulation</a> in Mendel Cooper's very useful <a href="http://www.tldp.org/LDP/abs/html/index.html">Bash Scripting Guide</a>.<a href="http://www.tldp.org/LDP/abs/html/string-manipulation.html"> </a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[famfamfam flag iconset yaml representation on ruby]]></title>
<link>http://nunojob.wordpress.com/?p=305</link>
<pubDate>Sun, 11 May 2008 16:22:09 +0000</pubDate>
<dc:creator>nunojob</dc:creator>
<guid>http://nunojob.wordpress.com/?p=305</guid>
<description><![CDATA[First download the flags from famfamfam into a folder called flags (pngs only,
no subfolders!).
Now ]]></description>
<content:encoded><![CDATA[<p>First download the <a href="http://www.famfamfam.com/lab/icons/flags/" target="_blank">flags from famfamfam</a> into a folder called flags (pngs only,<br />
no subfolders!).</p>
<p>Now in the bash:</p>
<p>[sourcecode language='php']<br />
cd flags<br />
wget http://www.iso.org/iso/iso3166_en_code_lists.txt<br />
ls > file.txt<br />
irb<br />
[/sourcecode]</p>
<p>Now your on the interactive ruby shell (irb).</p>
<p>[sourcecode language='ruby']<br />
# If you want to use this as a script just copy<br />
# the bash lines and put them as<br />
# system 'cd flags'<br />
# system 'wget ...' and so on</p>
<p># We start treating the output from the ls<br />
# open the ls output<br />
f = File.new 'file.txt'<br />
# place the file in lines<br />
lines = f.readlines<br />
# map those who have 2 digits codes<br />
lines = lines.select { &#124;line&#124; line.size == 7 }<br />
# get the 2 digits<br />
lines = lines.map { &#124;line&#124; line[0..1] }<br />
f.close</p>
<p># Then the iso file<br />
# open the iso file<br />
f = File.new 'iso3166_en_code_lists.txt'<br />
# get rid of the notes<br />
f.readline<br />
# place the file in iso<br />
iso = f.readlines<br />
# create a new hash<br />
hashed_iso = {}<br />
# select non empty lines<br />
iso.select { &#124;a&#124; !a.rstrip.empty? }.map do &#124;b&#124;<br />
  # remove the whitespaces and split in ';'<br />
  aux = b.rstrip.split ';'<br />
  # place info in the hash<br />
  hashed_iso[aux[1].downcase] = aux[0].capitalize<br />
end<br />
f.close</p>
<p># Now we cross information giving more<br />
# importance to what's in the iso.<br />
iso_famfamfam = hashed_iso.select {<br />
  # select those who have flags in famfamfam<br />
  &#124;k,v&#124; lines.member? k<br />
}.sort_by {<br />
  # sort them by the name the user will see<br />
  &#124;pair&#124; pair[1]<br />
}</p>
<p># Now we create the contents to store in the yaml file<br />
# create the yaml first line<br />
yaml_lines = "hash: \n"<br />
iso_famfamfam.each do &#124;pair&#124;<br />
  # for each pair, create the yaml<br />
  # representation and put in yaml_lines<br />
  yaml_lines < < '  ' + pair[0] + ': '<br />
                         + pair[1] + "\n"<br />
end </p>
<p>yaml_lines &#60;&#60; "array: ---\n"</p>
<p>iso_famfamfam.each do &#124;pair&#124;<br />
  yaml_lines << '- - ' + pair[0] + "\n  - "<br />
                            + pair[1] + "\n"<br />
end </p>
<p># put it in a file<br />
f = File.new 'flags.yml', 'w'<br />
f.write yaml_lines<br />
f.close</p>
<p>#sample for loading the yaml into ruby<br />
f = File.new 'flags.yml'<br />
fy = YAML.load f<br />
[/sourcecode]</p>
<p>Now you have your yaml representation of the flags. Do what you please. Personally I'm going to use the file to load it to Ruby when my Ruby on Rails app starts and use it as part of the registration system in the <a href="http://gitorious.org/projects/online-testing-system" target="_blank">Open Source Online Testing System.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Use multiple bash windows without losing your history]]></title>
<link>http://lessfaq.wordpress.com/?p=56</link>
<pubDate>Sat, 10 May 2008 11:03:32 +0000</pubDate>
<dc:creator>Vinod</dc:creator>
<guid>http://lessfaq.wordpress.com/?p=56</guid>
<description><![CDATA[Add the following lines in $HOME/.bashrc.

#Append the history rather than overwrite it
shopt -s his]]></description>
<content:encoded><![CDATA[<pre>Add the following lines in $HOME/.bashrc.

#Append the history rather than overwrite it
<strong>shopt -s histappend</strong></pre>
<pre>## Save the history after each command finishes
## (and keep any existing PROMPT_COMMAND settings)
<strong>PROMPT_COMMAND="history -a; $PROMPT_COMMAND"</strong></pre>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Bash equivalent for PHP realpath()]]></title>
<link>http://andy.wordpress.com/?p=174</link>
<pubDate>Fri, 09 May 2008 17:36:48 +0000</pubDate>
<dc:creator>Andy</dc:creator>
<guid>http://andy.wordpress.com/?p=174</guid>
<description><![CDATA[For all you PHP hackers trying to write a BASH script and looking for an equivalent for PHP&#8217;s ]]></description>
<content:encoded><![CDATA[<p>For all you PHP hackers trying to write a BASH script and looking for an equivalent for PHP's realpath function, try readlink. It can expand symbolic links and resolve relative paths like "./" and "../". In a shell script, try this:</p>
<p><code>MY_PATH=$(readlink -f $0)</code></p>
<p>Thanks to <a href="http://barry.wordpress.com/">Barry</a>.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Ausgefallen]]></title>
<link>http://daronn.wordpress.com/?p=451</link>
<pubDate>Fri, 09 May 2008 12:11:29 +0000</pubDate>
<dc:creator>daRONN</dc:creator>
<guid>http://daronn.wordpress.com/?p=451</guid>
<description><![CDATA[
Kommt mir bekannt vor&#8230;
via german-bash.org
]]></description>
<content:encoded><![CDATA[<p style="text-align:center;"><img class="alignnone size-full wp-image-452 aligncenter" src="http://daronn.wordpress.com/files/2008/05/ausgefallen.jpg" alt="" width="395" height="83" /></p>
<p>Kommt mir bekannt vor...</p>
<p>via <a title="German-Bash" href="http://german-bash.org" target="_blank">german-bash.org</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Perl vs BASH]]></title>
<link>http://selmys.wordpress.com/?p=3</link>
<pubDate>Fri, 09 May 2008 10:40:42 +0000</pubDate>
<dc:creator>selmys</dc:creator>
<guid>http://selmys.wordpress.com/?p=3</guid>
<description><![CDATA[A week ago on tuxmachines.org I spotted an item demonstrating how to reverse a file (left to right A]]></description>
<content:encoded><![CDATA[<p>A week ago on <a href="http://tuxmachines.org">tuxmachines.org</a> I spotted an <a href="http://linuxshellaccount.blogspot.com/2008/05/reversing-all-lines-in-file-on-linux-or.html">item</a> demonstrating how to reverse a file (left to right AND top to bottom) using perl. My first reaction was "WOW! That's a lot of code for a very simple problem". Using BASH command-line I would simply do this</p>
<p>cat datafile &#124; rev &#124; tac</p>
<p>Whew! That was a lot of work.</p>
]]></content:encoded>
</item>

</channel>
</rss>
