开发者

What does "cat foo foo foo does"?

开发者 https://www.devze.com 2023-03-30 19:08 出处:网络
hey i wana p开发者_如何学编程reparefor various basic commands for unix so for that i need this ans.

hey i wana p开发者_如何学编程repare for various basic commands for unix so for that i need this ans. what is the output of cat foo foo foo in unix?I m confused will it display the output of foo file three times or anything else that i may not know? any help is appreciated?

UPDATE: actually i m not having UNIX installed and i m just preparing for test.I know this question is not to be asked but there is no other means to me except this.and even i have searched for it.


Try using the manpages (man cat).

cat [-benstuv] [file ...]

The cat utility reads files sequentially [...]

Yes, it will display foo three times.


They will be considered as three different files, so you would get three time the content of foo


Display the contents of foo three times one after other. Better, read man cat


Funny, it looks like nobody noticed that it does more that replicating the contents of file foo?
It shows the content of the file does directly after three times showing the content of file foo!

Technically, cat does not look at the file names in the command line, except for reading the files.

That means it "does not know" that one file is used three times. What it means is that it does not make use of the information that a file name is repeated. But something like saving the content the first time, and write it out two more times would be invalid anyway - the file could have changed while reading the first time.

Concatenating the content of four files, that's what it does!

And - that's why cat is named cat - it is for concatenating files!

I mean, that title could really be a nice trick question - lots of confusion in few words.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号