You're viewing a comment by Mark and its responses.

Mark Permalink
February 17, 2009, 18:48
# On computer A with IP
$ cat file | nc -l -p 6666

And of course, if you've been following along for a week or two, you know that this (BING!) is a Useless Use of Cat!

Remember, nearly all cases where you have:

cat file | some_command and its args ...

you can rewrite it as:

some_command and its args ... < file

and in some cases, but not this one, you can move the filename to the arglist as in:

some_command and its args ... file

Just another Useless Use of the Internet...

Comment Responses

August 05, 2013, 04:26

I see your point and for everyone that doesn't see this tip, it's a great one.

I personally just prefer to use cat. It keeps the data flow a nice left-to-right, which makes it easier to read.

Data flow <------
cmd < file | cmd

Data flow -------->
cat file | cmd | cmd

Steve Massey Permalink
January 30, 2017, 00:18

you can do
<file cmd | cmd

which is the same as
cmd <file | cmd

but with the right flow

August 05, 2013, 21:47

That's fine until you get the redirect the wrong way around and blow away a file...

Reply To This Comment

(why do I need your e-mail?)

(Your twitter name, if you have one. (I'm @pkrumins, btw.))

Type the word "lcd_132": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.