Code Counter
0
Small amount of bash shell code to produce terminal output. I use this to keep alive ssh connections where the server will automatically disconnect a session where input is not received for a small amount of time.
Needs: A terminal that understands ansi.sys escape codes. Most modern interactive terminals. You might have limited success on serial terminals.
CAVEAT: Admittedly
watch date
would do the same job - but is less fun.
In use I have this in a function in my .bashrc
function keepalive () {
}
Needs: A terminal that understands ansi.sys escape codes. Most modern interactive terminals. You might have limited success on serial terminals.
CAVEAT: Admittedly
watch date
would do the same job - but is less fun.
In use I have this in a function in my .bashrc
function keepalive () {
}
0
Usage:
found('asdf',@array);
P.S. In perl 5.10 can be written as
use 5.010;
'asdf'~~@array;
found('asdf',@array);
P.S. In perl 5.10 can be written as
use 5.010;
'asdf'~~@array;
7
lavaramano
how to remove a string from a plain text using just grep.
6
lavaramano
how to sort words separated by a ','.
5
how to handle arrays in bash
7
This one-liner is great, it lists the commands you have used by popularity. At present, the 'cd' command wins in my history file with 140. Followed by ls (93) and ssh (56). What are your top 3 commands 
Snippet source: ibm

Snippet source: ibm
7
A lot of time shell scripts need to do some sort of math. Bash's innability to do floating point arithmatic has lead to some pretty neat workarounds, often times these workarounds are slow. If you need a lot of calculations done with speed, you'll find this snippet useful
9
Parsing newline-delimited data records in bash is simple, if you have this odd redirect up your sleeve. An annoying thing about bash is that it usually equates all whitespace characters, so the first block in the snippet won't let you use a file linewise, but will end up echoing each whitespace-delimited token on a separate line.
bash provides the "read" builtin which can be used to differentiate between newlines and spaces.
bash provides the "read" builtin which can be used to differentiate between newlines and spaces.
8
This little tool is pretty useful for administrators who wear the hat of both system admin and DBA on Linux/MySQL boxes. I wrote it as kind of a joke for our Perl developers, but now I use it just about every day for everything from at prompt hackups to full on table space utilization monitoring scripts.
The snippet has the library script that you can source into scripts that actually do work, as well as a script that uses the functions in the libraries. Anyone who has used the C API should be able to relate to using this script.
It's pretty fast and lightweight. It makes only one external call to mysql and sed per query. The rest is all bash builtins. Requires bash > 3.0
The snippet has the library script that you can source into scripts that actually do work, as well as a script that uses the functions in the libraries. Anyone who has used the C API should be able to relate to using this script.
It's pretty fast and lightweight. It makes only one external call to mysql and sed per query. The rest is all bash builtins. Requires bash > 3.0
6
This adds your ssh public key to the authorized_keys on a remote server. The key file in the snippet is called id_dsa.pub, yours may have another name but this is standard for DSA encryption.
To learn more about ssh I heartly recommend this: SSH tips and tricks
To learn more about ssh I heartly recommend this: SSH tips and tricks









