Quantcast
Channel: Is it a UUOC (useless use of cat) to redirect one file to another? - Unix & Linux Stack Exchange
Browsing latest articles
Browse All 8 View Live

Answer by krazykyngekorny for Is it a UUOC (useless use of cat) to redirect...

If it works, don't fix it. I would use cat < file1 > file2 and not sweat the PC of the semantics.

View Article


Answer by Jens for Is it a UUOC (useless use of cat) to redirect one file to...

In addition to all the good answers, you can avoid a UUOC by simulating a cat: awk 1 file1 > file2 # For line-oriented text, not binaries. dd if=file1 of=file2 # Works for binary files, too. # many...

View Article


Answer by Kaz for Is it a UUOC (useless use of cat) to redirect one file to...

< from > to doesn't work because there is no command there; no process. The shell opens/creates the files and arranges the redirections (meaning that the file descriptors referencing these files...

View Article

Answer by Stéphane Chazelas for Is it a UUOC (useless use of cat) to redirect...

In zsh, the shell where < file1 > file2 works, the shell does invoke cat. For a command line that consists only of redirections and no command nor assignments, zsh invokes $NULLCMD (cat by...

View Article

Answer by tniles for Is it a UUOC (useless use of cat) to redirect one file...

It is not, because as others have pointed out, the behavior in question is shell-dependent. As you (the OP) have pointed out, this is a bit of a pedantic, maybe even humorous?, sort of topic. However,...

View Article


Answer by PSkocik for Is it a UUOC (useless use of cat) to redirect one file...

cat < file1 > file2 is not a UUOC. Classically, < and > do redirections which correspond to file descriptor duplications at the system level. File descriptor duplications by themselves...

View Article

Answer by tastytea for Is it a UUOC (useless use of cat) to redirect one file...

< file1 > file2 Seems to be shell-dependent, on zsh it works, on bash not. edit: deleted false statement

View Article

Is it a UUOC (useless use of cat) to redirect one file to another?

If I want to make the contents of file2 match the contents of file1, I could obviously just run cp file1 file2. However, if I want to preserve everything about file2 except the contents—owner,...

View Article

Browsing latest articles
Browse All 8 View Live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>