I have a txt-file that has a (changing) number as content in it. ex: “12345”
I need to put this (changing) number in a variable. This number is filtered out of a html-page (with a sed-command).
Who can give me a tip?
(this is the script)
#!/bin/bash
wget nos.nl/uitzending/nos-journaal
grep ‘data-id=.*"’ nos-journaal > dataid.txt #get the data-id number
sed -i ‘s/data-id="//g’ dataid.txt #clean up the number, remove quotes and spaces and junk
sed -i ‘s/"//g’ dataid.txt #
sed -i ‘s/ //g’ dataid.txt #
#!/bin/bash
wget nos.nl/uitzending/nos-journaal
grep 'data-id=.*\"' nos-journaal > dataid.txt #get the data-id number
sed -i 's/data-id=\"//g' dataid.txt #clean up the number, remove quotes and spaces and junk
sed -i 's/\"//g' dataid.txt
sed -i 's/ //g' dataid.txt
MY_VAR=$(cat dataid.txt) # Load into variable
echo $MY_VAR # Print variable to screen
ps: i have to add a logic in the script that will check id web03 is present (and then wget it) or web02 or web01 (these are the same video’s but then in decreasing sharpness-order)