Awk command without input file

i have a requirement to compare two time stamps in IF condition and return true whenever the second timestamp is greater than first, i will also be checking, if the timestamp in HHMMSS format( 6 digit time stamp ).Im able to achieve it using awk, however i dont want to give any input file to awk and i will not be able to give input from command line as im running this in a script.

starttime = HHMMSS
endtime = HHMMSS

awk -v val1=$starttime -v val2=$endtime '{ if ( length(val1)==6 && length(val2)==6 && val2 > val1 ) print }' filename

in the above syntax i want to eliminate the file as im not doing any thing against the file and also if awk logic is sucessful my script should continue else it should exit the script.

Can we achieve all this in a single command without using awk command.

did you try by assigning to a variable?

You can do that in the begin segment

awk -v val1=$starttime -v val2=$endtime 'BEGIN{ if ( length(val1)==6 && length(val2)==6 && val2 > val1 ) print "yes"}'

Careful with timestamps around midnight..

Thanks Scrutinizer. it worked

im using this command in windows batch script. Can i assign the output of this command to windows varaible.i tried in unix format using grave accent (`) but it is not working. i want to assign this to a varaible in windows like

set check=`awk -v val1=$starttime -v val2=$endtime 'BEGIN{ if ( length(val1)==6 && length(val2)==6 && val2 > val1 ) print "yes"}'`