2008
07.08

boredom

boredom led me to write a command that does the same thing but three different ways;

assume that the file that is being cat to use for this example contains:

line 1
line 2
<form id="form_login" name="form_login" method="post" action="session_id=XXXXXx.xxxxx.NAM1&locid=0&lf=0&i>

and i need NAM1 only. well, i actually need the three letter code and number. it remains in the same location in every file but changes depending on the file.

grep "form id" | awk '{print $5}' | cut -b35-200 | cut -d. -f2 | cut -d"&" -f1
awk '/form id/ {print $5}' | awk '{gsub(/\.|\&/," ");print $3}'
awk '/form id/ {print $5}' | cut -d. -f3 | cut -d"&" -f1

the first line probably makes zero sense since the first cut command is calling bytes 35-200 and with this example it does not quite fit, but trust me, it works with the actual file (had to change as requested)

i know that there are still a ton of different ways (some more effective and efficient) but these were just quick bursts and these are just snippets of the original commands (i was processing the output from another command).

i love boredom…..

p.s. – i know that it might not work properly, ill get around to posting a better example file to use.

No Comment.

Add Your Comment