On Sun, 2013-04-07 at 21:15 -0700, Ganesha Computes wrote:
> Mohan R,
> 
> What's the difference between?

You question itself have answer, you are passing the file as "argument",

$ cat testfile.txt

and you are passing the file as "standard input",

$ cat < testfile.txt

Its all depends on how the program (in this case 'cat') has been
written. You can write your program to get input file from argument as
well as get input file from stdin.

Here is a simple example:

Mycat.bash:
------------
#!/bin/bash
test "${#}" -le "0" && INPUTDATA=$(cat) || INPUTDATA=$(cat "${1}")
echo "${INPUTDATA}"


$ chmod 755 ./Mycat.bash
$ cat > testfile.txt
hello world
$ Mycat.bash testfile.txt
hello world
$ Mycat.bash < testfile.txt
hello world
$ 

Thanks,
Mohan R

_______________________________________________
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc

Reply via email to