[home] [r]

maybe this is a blog, maybe a rant, yet to be determined!

Execute ELF files without execute permission!

# typically /lib64/ld-linux-x86-64.so.2
loader=$(objcopy -O binary -j .interp /tmp/hello /dev/stdout)
chmod -x /tmp/hello
$loader /tmp/hello
hello, world!
		

awk: reverse sort

This one is for reverse sorting (not-nested) html table rows, change RS to sort others.
awk -vRS='' 'BEGIN { PROCINFO["sorted_in"] = "@ind_num_desc"; } {lines[i++]=$0} END { for (i in lines) { printf "%s%s", lines[i], RS ; } }' 

transmission: don't download large no of file at once

This one depends on files having very predictable name.
id=456
# col=22 cutoff=24
transmission-remote -t "$id" -G "$(transmission-remote -t "$id" -if | awk '$4 == "Yes"{ if ($22 > 24) { sub(/:/, ""); printf "%s,", $1} }' )"