LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   redirection < operator not working pls help (https://www.linuxquestions.org/questions/linux-newbie-8/redirection-operator-not-working-pls-help-477167/)

Fond_of_Opensource 08-25-2006 01:10 AM

redirection < operator not working pls help
 
Redirection operator < is used to read input from a file to a command.

I tried
$cal < myfile

myfile contains data:
2000

but the above command is not working. I wanted to make the cal command read input from the file 'myfile' and display the calendar of year 2000. I am using the I/O redirection operator in the above command. Why the above command is not working? How to make it to work??

pls help,

thanks in advance.

zhangmaike 08-25-2006 01:42 AM

cal does NOT read from stdin. The < operator sends the contents of the specified file to the standard input (stdin) of the specified program. Since cal does not read from stdin, this will not work. Check the cal manpage (man cal).

If you want to print the calendar for 2000, just do:
Code:

cal 2000
If you really must read this year from a file, do:
Code:

cal $(<myfile)
Which will read from myfile, and pass the contents as arguments to cal.

bikecheng 08-25-2006 02:32 AM

thank you!that is my problem too.

bikecheng 08-25-2006 02:35 AM

thank you!
that is my problem too.


All times are GMT -5. The time now is 09:24 PM.