I’ve got a one-liner like this:
date +%H | perl -ne 'printf "%02d", $_ - ($ARGV[0] - 1);' 1
It says:
Can't open 1: Datei oder Verzeichnis nicht gefunden.
The error message means “File or directory not found”.
I want it to take both the output from date and the commandline argument at the same time.
Essentially it should get me the current hour minus the argument minus one. If there are better ways to achieve this, I’ll happily accept them. I’d still be grateful about an explanation as to why this doesn’t work.
Let’s assume it’s after 10am now.
Param Output
1 10
2 09
3 08
The result might be yesterday or even further back in the past, it does not make much sense to print just the hour.
Whereever possible, use a standard datetimestamp, such as RFC3339 which is in wide use.
Your Perl one-liner deparses to:
… because of
-n.ARGV:But you have no filenames as arguments.