Showing posts with label One-liner. Show all posts
Showing posts with label One-liner. Show all posts

Wednesday, 9 September 2009

Random Musings - Day #252

9/9/9
Today was 9/9/9 and thankfully that day passed through near enough quietly.

Twitter RANT
Decided to just use twitter as following tool. Maybe I am not using it right but I think it's useless if you want to talk to someone new, really... You can't direct message unless they are following you. How the hell are you supposed to get a message across @someone and everyone potentially could see your tweet. No thanks. RANT OVER.

BTW my twitter is Shy 90, which I am now only tweeting useless 90s facts.

Internet Radio
A couple more internet radio stations to look out for. Some DJs that I know of are at Rockin Radio. Also found fallen sword via twitter.

Java certify me
Sun is telling me to upgrade my Java Certification.

More one-liners
This one was done on-the-fly. Figure out what the awk does?

cat all-result.txt | grep 10.0.0.1 | grep HIGH | grep 'MS0' | awk '{where=match($0,"MS0?-???"); print substr($0,where,8)}'


Turns out it was easier to replace an enhanced grep...
grep -o "MS[0-9+]-[0-9]*."


As shown in the modified one-liner...

cat all-result.txt | grep 10.0.0.1 | grep HIGH | grep 'MS0' | grep -o "MS0[0-9]-[0-9]*." | sort | uniq


To read a argument from shell... "READ IPS"

Thursday, 27 August 2009

Random Musings - Day #239

More one-liners
No, this is not comedy but there are so many ways to kill a dead donkey. All these one-liners do the exact same thing and that's add a tab and 'Y' at the end of each line in a file...

for I in `cat t.txt`; do echo -e "$I\tY"; done

for I in `cat t.txt`; do printf "%s\tY\n" $I ; done

cat t.txt | xargs -i echo -e "{}\tY"


I prefer using the for construct in shell, as I can remember that and you can find a way of doing things with it. That's just a personal preference. Here's another example, generating IP address on-the-fly and look the dns name up.

for I in $(seq 255); do host 192.168.0.$I; done