Answer the question
In order to leave comments, you need to log in
How to display the contents of a file with only the echo and ls commands?
The point is this. There is a file called -text.txt- (with - at the beginning and end). Only echo and ls commands are available, how can I output its contents?
PS The file was created by root, the commands are executed by the user
Answer the question
In order to leave comments, you need to log in
echo `<-text.txt-`
The hacker of me is so-so, but it worked:
The options above are correct. If you can’t display the contents, then maybe you need to change the file permissions?
chmod 777 -text.txt-
echo $(<./-text.txt-)
The owner of the file is not important, it is the availability of access that matters. If there is no access to read, then that's it, we've arrived.
So the shortest option was indicated here:
echo `<-text.txt-`
But I think the user was worried about the minus in the name, and not the presence of cat, and it’s easy to deal with this:
cat -- -text.txt-
cat ./-text.txt-
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question