Skip to content

Category: english

“The obsolescence of an implementation must be measured against other existing implementations, not against unrealized concepts.” The Mythical Man-month – Essays on Software Engineering. Freederick P. Brooks, Jr.

Bash Brace Expansion

photo by whiskeyandtears at https://www.flickr.com/photos/whiskeyandtears/2140154564

[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]

[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 .
.
./project1
./project1/tst
./project1/bin
./project1/lib
./project1/src
./project2
./project2/tst
./project2/bin
./project2/lib
./project2/src
[/bash]

[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
a
b
c
d
e
f
1
2
3
4
5[/bash]

The examples below requires Bash version 4.0 or greater.

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

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

“Baste a quem baste o que lhe basta
O bastante de lhe bastar!
A vida é breve, a alma é vasta;
Ter é tardar.”

Fernando Pessoa

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

heredoc to feed an interactive program

Let this interactive.sh be the interactive program:
[bash]#!/bin/sh
read input1
read input2
echo $input1 $input2
[/bash]

This is a script feed.sh (in the same directoty) that uses heredoc to feed two lines to interactive.sh:
[bash]#!/bin/sh
./interactive.sh << EOF
asdf
zxcv
EOF
[/bash]

It work as:
[bash]$ ./feed.sh
asdf zxcv
[/bash]

“and I know too well that these arguments from probabilities are impostors, and unless great caution is observed in the use of them they are apt to be deceptive-in geometry, and in other things too” Socrates, in Phaedo by Plato. 399 BC.

Jeep Wrangler ASCII Art Collection

Some ASCII/ANSI/Shift_JIS/Unicode art of Jeep Wranglers. They are easy to modify and introduce your own customizations.

These I found on the web:

  __________ 
 |          | 
 |______(*)_| 
 /\__----__/\ 
/_/()||||()\_\ 
|_\ o||||o /_| 
|----Jeep----| 
|_|        |_| 


                   _.------------------.
                 .'____________________|
                 //    _||||  | |  | | |
          ______//_\__j_|||"--" "--" | |  _
         /-----+-|p  ==,|||__________|_|-|W|
        _j,====. |b_____|||  _____     | |W|
       |_) ,---.`.`------'|.',---.`.___|_|W|
         `/ .-. \\`======__// .-. \`-----'""
          \ `-' / """""""   \ `-' /
           `---'             `---'     hjw

  ____        
 /_/CL\___     
 \_,.__,._)    
---`'--`'--MK  
  ____
 |_| L\___
 |_,.__,._)
---`'--`'--MK

/l ,[____],
l---L -O||||||O-
()_)-()_)-o-)_)

    ______ooooo
  /__|_|_,\____\,___
  |_---|_|__|---O|||O
_.(o)_)__(o)_)--o-)_) 

               ∩_∩
        // ̄ヽ_( ・(ェ)・)  ____
       | ̄ ̄|_ (⊃/ ̄ ̄ ̄(O|||||O)
 .⌒ヽ ,;;; | / ̄ヽ ||___|// ̄ヽ ̄| |||||/ヽ
 (";"':;.):;゙ |_| ◎ |___ | ◎ .| |=======
   ⌒;:ヽ;; ヽ_//     ヽ_// ヽ_//
~~~~´゙`゙゙´´ ~~~~゙`゙´``´゙`゙゙´´ ~~゙゙´``´`´ ~~~


,[____l,
_-o||||o-_
()_)¯¯ )_)

O|||||||O

•IIIIII•

This one I created:

 
 â—„
  ╽██████████████       
  ▓█ ██ █✌ຈل͜ຈ █▄▄▄▄▄
  ▓█████████████⚪║║║║⚪█ 
  ═█▓▓██████▓▓▀████ºº███▀
    â–“â–“ â–“â–“   â–“â–“       â–“â–“

This one is a remix of one from hjw (Hayley Jane Wakenshaw) with an extra door, i.e. the Jeep Wrangler Unlimited.


                   _.---------------------.
                 .'_______________________|
                 //    _|||    || |   | | |
          ______//_\__j_|||____|| "---" | |  _
         /-----+-|p  ==,|||p ==,|_______|_|-|W|
        _j,====. |b_____|||b    /_____    | |W|
       |_) ,---.`.`------'|----.',---.`.__|_|W|
         `/ .-. \\`======__====// .-. \`---'""
          \ `-' / """""""  """" \ `-' /
           `---'                 `---'  

A remix of this post from @TwitAA_bot:

  __________ ⌒彡
 |          |冫、)
 |__________|` /
 /\__----__/\ /
/_/()||||()\_\
|_\ o||||o /_|
|------------|
|_|        |_|

Sources:

if host pings execute command

[bash]#!/bin/sh
HOST="silveiraneto.net"
if ping -c 1 $HOST > /dev/null
then
echo your command
fi
[/bash]

  • replace silveiraneto.net 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