I have this command to review the last 10 min of the log:
perl -MDate::Parse -ne 'print if/^(.{15})\s/&&str2time($1)>time-600' /path/log
Now I want to put it in a script and put a variable instead of 600, to be able to modify the time more easily
#!/bin/bash
lasttime="600"
perl -MDate::Parse -ne 'print if/^(.{15})\s/&&str2time($1)>time-$lasttime' /path/log
# script does not end here. Run other commands like sed, grep etc. Why it should be in bash
But nothing comes out on the screen. But if I remove the variable it works fine
#!/bin/bash
perl -MDate::Parse -ne 'print if/^(.{15})\s/&&str2time($1)>time-600' /path/log
What should I modify so that it accepts the variable?