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

Answer:

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.

e.g.

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