Wednesday, September 24, 2014
Python one liner to get next ascii char
python -c "print unichr($(echo "$(ascii -st $1 | awk '{print $2}') + 1" | bc))"
Sunday, September 21, 2014
Search RAR archives with grep
ls *.rar | xargs -t -I {} rar lf {} | grep -i <something youre looking for>
The -t option to xargs announces the command line that it is processing (in this case which rar file), and the rar lf lists the files in the rar archive.
The -t option to xargs announces the command line that it is processing (in this case which rar file), and the rar lf lists the files in the rar archive.
Wednesday, September 17, 2014
Quick webserver w/ netcat
{ echo -ne "HTTP/1.0 200 OK\r\nContent-Length: $(wc -c < <(ls))\r\n\r\n"; cat <(ls); } | nc -l 8080
You can replace <(ls) with whatever script or file to display or command to
execute that you like
http://192.168.1.<your ip>:8080
(Thanks to https://kb.ip-connect.de/index.php?id=422 for the tip)
Or.. if you want to execute a command upon visiting the website url:
{ echo -ne "HTTP/1.0 200 OK\r\nContent-Length: $(wc -c < <(ls))\r\n\r\n"; cat <(ls); } | nc -l 8080 && <command>
Sunday, September 14, 2014
Nc definition of a word from dict.org
$ echo "define wn hello" | nc dict.org 2628
220 pan.alephnull.com dictd 1.12.1/rf on Linux 3.14-1-amd64 <auth.mime> <4420661.15757.1410721786@pan.alephnull.com>
150 1 definitions retrieved
151 "hello" wn "WordNet (r) 3.0 (2006)"
hello
n 1: an expression of greeting; "every morning they exchanged
polite hellos" [syn: {hello}, {hullo}, {hi}, {howdy}, {how-
do-you-do}]
.
250 ok [d/m/c = 1/0/16; 0.000r 0.000u 0.000s]
220 pan.alephnull.com dictd 1.12.1/rf on Linux 3.14-1-amd64 <auth.mime> <4420661.15757.1410721786@pan.alephnull.com>
150 1 definitions retrieved
151 "hello" wn "WordNet (r) 3.0 (2006)"
hello
n 1: an expression of greeting; "every morning they exchanged
polite hellos" [syn: {hello}, {hullo}, {hi}, {howdy}, {how-
do-you-do}]
.
250 ok [d/m/c = 1/0/16; 0.000r 0.000u 0.000s]
Saturday, September 13, 2014
Pass variables by reference in Bash
function dref() { echo $(eval expr \"\$$1\"); };
$ dref PATH
/usr/local/bin:/usr/bin:...
$ dref PATH
/usr/local/bin:/usr/bin:...
Friday, September 5, 2014
Bash recursive subtraction function
#!/usr/bin/env bash
#recursive subtract, arg1 - arg2
function f_r_s() {
if [[ $1 -eq $2 ]]; then
echo 0;
elif [[ $1 -gt $2 ]]; then
echo "1 + $(f_r_s $(echo "$1 - 1"|bc) $2)" | bc;
else
echo "f_r_s(), reverse the args and try again";
fi;
}
#recursive subtract, arg1 - arg2
function f_r_s() {
if [[ $1 -eq $2 ]]; then
echo 0;
elif [[ $1 -gt $2 ]]; then
echo "1 + $(f_r_s $(echo "$1 - 1"|bc) $2)" | bc;
else
echo "f_r_s(), reverse the args and try again";
fi;
}
Subscribe to:
Posts (Atom)