Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Jul 252013

File content redirection without using cat


It is not uncommon that people have abused the command `cat` for many purpose, e.g. file I/O redirection

cat data.txt | sed 's/foo/bar/s'

You can avoid the cat command by the following commands:

data.txt < sed 's/foo/bar/s'
sed 's/foo/bar/s' < data.txt

Both directions are okay.

In fact, when you better understand the usage of some commands, you might find out that redirection is completely not needed.


sed 's/foo/bar/s' data.txt

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>