In the linux terminal, you need to read the file -data.txt- only with the ls command. Any ideas?
1 answer
using the ls command
This is where the trick lies.
After all, the program /bin/ls this, of course, does not know how.
but the command executed by the shell can run an arbitrary program. for example, /bin/cat . Well, to determine the actions of the team can be different. for example, using the built-in alias shell command (to create command aliases):
$ alias ls=/bin/cat check:
$ ls файл здесь будет результат выполнения программы /bin/cat с аргументом "файл", т.е. содержимое этого файла or by defining a function. First we delete the alias:
$ unalias ls and create a function. either so:
$ function ls { /bin/cat $@; } either way (just another syntax):
$ ls () { /bin/cat $@; } verification will give a similar result.
- Well, this is some kind of perverted consciousness that a teacher should have in order to introduce such subtleties into the tasks. So, it is necessary to enter the name on chicaneism, but not on programming or system administration. - 0andriy
|
catfor this? - LFC