Skip to content

Tag: Linux

Bash Brace Expansion

photo by whiskeyandtears at

[bash]$ echo {0..9}
0 1 2 3 4 5 6 7 8 9[/bash]

[bash]$ echo b{a,e,i,o,u}
ba be bi bo bu

[bash]$ echo x{0..9}y
x0y x1y x2y x3y x4y x5y x6y x7y x8y x9y[/bash]

[bash]$ echo {a..z}
a b c d e f g h i j k l m n o p q r s t u v w x y z[/bash]

[bash]$ echo {1..3} {A..C}
1 2 3 A B C[/bash]

[bash]$ echo {1..3}{A..C}
1A 1B 1C 2A 2B 2C 3A 3B 3C[/bash]

[bash]echo {a,b{1,2,3},c}
a b1 b2 b3 c[/bash]

[bash]$ mkdir -p {project1,project2}/{src,tst,bin,lib}/
$ find .

[bash]$ echo {{A..Z},{a..z}}
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z[/bash]

[bash]$ for i in {a..f} 1 2 {3..5} ; do echo $i;done

The examples below requires Bash version 4.0 or greater.

[bash]$echo {001..9}
001 002 003 004 005 006 007 008 009

[bash]$ echo {1..10..2}
1 3 5 7 9

find a process running a deleted library

sudo find /proc -maxdepth 2 -name maps -exec grep -HE ‘\(deleted\)’ {} \; | cut -d/ -f3 | sort -u | xargs –no-run-if-empty ps

Looking for libssl in specific:

sudo find /proc -maxdepth 2 -name maps -exec grep -HE ‘/libssl\.so.* \(deleted\)’ {} \; | cut -d/ -f3 | sort -u | xargs –no-run-if-empty ps

Killing all process using a deleted version of libssl:

sudo find /proc -maxdepth 2 -name maps -exec grep -HE ‘/libssl\.so.* \(deleted\)’ {} \;| cut -d/ -f3 | sort -u | xargs –no-run-if-empty sudo kill

if host pings execute command

if ping -c 1 $HOST > /dev/null
echo your command

  • replace for your desired hostname or ip
  • ping sends only one package (-c 1) and ignores the text output
  • a ping is successful returns 0 and the if proceeds
  • replace the echo line with your command

printing only odd or even lines using sed

$ cat AtoF

Print only odd lines

sed -n 'p;n' AtoF

-n suppress automatic printing of pattern space, p print the current pattern space, n read/append the next line of input into the pattern space.


$ sed -n 1~2p AtoF

-n suppress automatic printing of pattern space, 1~2 from the 1st line match every line every 2 steps, p print the current pattern space. sed -n 0~p has the same effect . print only the even lines.

Print only even lines

$ sed -n 'n;p' AtoF 


$ sed -n 2~2p AtoF

0~2p would also work. I prefer

DIY recycle your old tv

When I came here to this room I found this old big tv laying around. Old but perfectly functional.

First I put a tv cable on it with hundreds of channels but after one month I realized that mostly of them are crap and I was watching everything on my laptop (mostly shows from Netflix and BitTorrent). Obviously I wanted to connect my laptop video output on it.  As an old television it doesn’t have any HDMI port. It have a RCA video and audio ports so after some research I bought a VGA-to-RCA converter. Besides watch movies on it there is a lot of cool things I could do with it to decorated the room or create a environment while we are jamming.

In this article I’ll show how to create a fireplace.

You will need

Getting a high definition fireplace video

You can search in Youtube for high definition fireplace videos.

There is a lot of ways to extract the videos from Youtube and it’s not the point explain it here but I can say one the best ways today is using JDownloader. Using it you can extract sound and video in any available resolution.

Choose a fireplace video and download the highest resolution available (usually 720p). Here I stored it at /home/silveira/Videos/fireplace_hd.flv.

Screen layout

I’m using the TV as a second display in the right. The width of my laptop monitor is 1920.

Creating a shortcut

First, right click in the upper panel of Gnome and select Add to Panel.  Select the Custom Application Launcher option.

Let’s fill it like this:

On the command put:

/usr/bin/mplayer /home/silveira/Videos/fireplace_hd.flv -nosound -loop 0 -geometry +1900+0 -fs


  • /usr/bin/mplayer the mplayer full path (probably you have the same path but you can try “whereis mplayer” in a terminal to find it).
  • /home/silveira/Videos/fireplace_hd.flv as I said, where I put the video.
  • -nosound no sound. :) Usually I have some music playing so I don’t want any fire sound. But if you want  the fire crackling sound omit this parameter.
  • -loop 0 the video I took have 10 minutes. If I put -loop 6 it would loop for 1 hour. Zero means infinite times.
  • -geometry +1900+0 you can specify the size of the screen and position but here I’m justing saying I want it on horizontal position 1900 (bigger than my first screen) so it goes to the tv.
  • -fs fullscreen

Now drink the wine and cheese in front of your low carbon footprint fireplace.  ;)


Now you can use the same idea and make an virtual aquarium, ant farm, an interactive art piece or anything!