I need to create only one file with name is the result of the command
ls -l | head -2.
I can’t use environment variables. The filename must contain newline symbols.
I’ve tried to use
touch 'ls -l | head -2', but it hasn’t worked.
Here is Solutions:
We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.
You can use the output of that command directly as the input of touch:
touch "$(ls -l | head -2)"
The quotes are important, as there are bound to be spaces and a newline in the output of the
ls -l | head -2 part.
Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂