How to Check value for an input element after fetching contents of page using cUrl

0

I am trying to download a page using cUrl. I have saved the page to a file and I then grep on it to extract the value of the text field. The text field appears multiple times and I just need one value. After doing

grep -i -e 'accessStore' t.txt,

the output of is

 <input type="text" name="accessStore" id="accessStore" value="ABCDEFGHIHKLOMNOPQEUDNSHQENGJW45"/>
 <input type="text" name="accessStore" id="accessStore" value="ABCDEFGHIHKLOMNOPQEUDNSHQENGJW45"/>
 <input type="text" name="accessStore" id="accessStore" value="ABCDEFGHIHKLOMNOPQEUDNSHQENGJW45"/>

I am using a linux box. I need to extract the value ABCDEFGHIHKLOMNOPQEUDNSHQENGJW45.

I know I can use sed or awk but I have never used it.

panxpress

Posted 2016-02-16T11:11:57.250

Reputation: 3

Answers

0

The one possible code of several others possible would look like this:

awk 'sub(/.*accessStore.*value="/,"") { sub(/".*/, ""); print; exit}' t.txt

Promise me you will read the awk manual until you understand how it behaves.

Gombai Sándor

Posted 2016-02-16T11:11:57.250

Reputation: 3 325

Works Great. I was parsing the string manually in the code until now. This worked. Thx. – panxpress – 2016-02-16T19:57:31.823