Tag Info

New answers tagged

4

Isn't cat reading from the stdin and stores that that into file "filename"? Yes, when cat does not have any filename arguments (or if one of the files is the minus character -), it reads from stdin. Perhaps use of the word "never" by the book is a bit misleading, because: Is the above excerpt from the book just saying that only the particular form ...


3

The mouse is normally accessible under Linux as a device under /dev/input and there is a virtual device /dev/input/mice that allows you to receive input from all mice in the system through a single device. This mouse device is not normally connected to the standard input of any process though. If you are using a graphical environment then the X11 server is ...


2

What is it you are missing? You seem to have understood everything. The > file sends the output to file and 2>&1 sends standard error to standard output. The final result is that both stderr and stdout are sent to file. To illustrate, consider this simple Perl script: #!/usr/bin/env perl print STDERR "Standard Error\n"; print STDOUT "Standard ...


5

You just have to read it left to right: > file --> redirect all thing from stdout to file.(You can imagine you have a link, point-to-point from stdout to file) 2>&1 --> redirect all thing from stderr to stdout, which is now pointed to file. So conclusion: stderr --> stdout --> file You can see a good reference here.


2

There are no "rules" as such. Some programs take input from STDIN, and some do not. If a program can take input from STDIN, it can be piped to, if not, it can't. You can normally tell whether a program will take input or not by thinking about what it does. If the program's job is to somehow manipulate the contents of a file (e.g. grep, sed, awk etc.), it ...


8

This is an interesting question, and it deals with a part of the Unix/Linux philosophy. So, what is the difference between programs like grep, sed, sort on the one hand and kill, rm, ls on the other hand? I see two aspects. The filter aspect The first kind of programs is also called filters. They take an input, either from a file or from STDIN, modify ...


12

There are two common ways to provide inputs to programs: provide data to STDIN of the processes specify command line arguments kill uses only command line arguments. It does not read from STDIN. Programs like grep and awk read from STDIN (if no filenames are given as command line arguments) and process the data according to their command line arguments ...


1

If I understood you correctly, you can use tee for this purpose. In the Bash script, let's assume the following line runs your compiled C program: ./my_program Replace that with: printf "%s\n" "my input here" | tee /dev/tty | ./my_program This will print my input here to your terminal device and pipe it to ./my_program on its stdin so it can read it.



Top 50 recent answers are included