How do I use GNU touch to update a file called -?
How do I use GNU cat to display a file called -?
I'm running:
% cat --version | head -n1
cat (GNU coreutils) 8.29
% touch --version | head -n1
touch (GNU coreutils) 8.29
Firstly, touch:
% touch -
% ls -l
total 0
% touch -- -
% ls -l -- -
ls: cannot access '-': No such file or directory
Ok, I'll give up on creating a file with touch. Let's create it with date instead:
% date > -
% ls -l -
-rw-r--r-- 1 ravi ravi 29 Sep 8 19:54 -
%
Now, let's try to cat it:
% cat -
% # I pressed ^D
% cat -- -
% # Same again - I pressed ^D
I know I can work around with:
% > -
and
% cat < -
But why don't these GNU utils support the convention that -- means that everything following is treated as a non-option?
How do I use these tools in the general case, for example I have a variable with the contents -?