I'm looking for a Linux command that does literally nothing, doesn't output anything, but stays alive until ^C.  while true; do; done is not a good solution, because it is CPU intensive.
123988
I have a program which produces useful information on stdout but also reads from stdin. I want to redirect its standard output to a file without providing anything on standard input. So far, so good: I can do:  program &gt; output   and don't do anything in the tty.  However, the problem is I want to do this in the background. If I do:  program &gt; output &amp;   the program will get suspended ("suspended (tty input)").  If I do:  program &lt; /dev/null &gt; output &amp;   the program terminates immediately because it reaches EOF.  It seems that what I need is to pipe into program something which does not do anything for an indefinite amount of time and does not read stdin. The following approaches work:  while true; do sleep 100; done | program &gt; output &amp; mkfifo fifo &amp;&amp; cat fifo | program &gt; output &amp; tail -f /dev/null | program &gt; output &amp;   However, this is all very ugly. There has to be an elegant way, using standard Unix utilities, to "do nothing, indefinitely" (to paraphrase man true). How could I achieve this? (My main criteria for elegance here: no temporary files; no busy-waiting or periodic wakeups; no exotic utilities; as short as possible.)
42393
On the command line, I can redirect or pipe output of a command to a file or another command using the &gt; or | operator after the command. I have come across a less standard situation that I would like to redirect the output to a file, but I don't seem to have the oppurtunity to redirect it:  When at a new terminal,  [chiliNUT ~]$   if I press Tab without typing anything first, I get asked   display all 1725 possibilities? (y or n)   and if I then type y, I get a nice long list of different commands. How can I redirect or pipe this output to a file? I don't seem to get the chance to type &gt; myfile.txt anywhere.  Using CentOS release 6.4 (Final).
84795
Do not run this command to 'test' it unless you are prepared for a crash and/or force-rebooting your system.  I was in my Virtualbox running 12.04 trying to compile an app, and while waiting I happened to chance upon a forum where a comment said:   Try :(){ :|: &amp; };:  Fun, too, and doesn't need root.  Without thinking, I ran it in my gnome-terminal. It made my 12.04(in Virtualbox) lag so badly, I had to shut it down. My question is what does this command do?   :(){ :|: &amp; };:
40147
On Linux, I want to send a command string (i.e. some data) to a serial port (containing control characters), and listen to the response (which also usually might contain control characters).   How can I do this as simplest as possible on Linux? An example is appreciated!
99088
How might I go about limiting the execution time of a command line program in windows? I know in linux there is timeout/timelimit available, but I have been unable to find similar utilities for windows.
106558
I'd like to automatically kill a command after a certain amount of time.  I have in mind an interface like this:  % constrain 300 ./foo args   Which would run "./foo" with "args" but automatically kill it if it's still running after 5 minutes.  It might be useful to generalize the idea to other constraints, such as autokilling a process if it uses too much memory.  Are there any existing tools that do that, or has anyone written such a thing?  ADDED: Jonathan's solution is precisely what I had in mind and it works like a charm on linux, but I can't get it to work on Mac OSX.  I got rid of the SIGRTMIN which lets it compile fine, but the signal just doesn't get sent to the child process.  Anyone know how to make this work on Mac?  [Added: Note that an update is available from Jonathan that works on Mac and elsewhere.]
38007
How can you suppress the Terminated message that comes up after you kill a process in a bash script?  I tried set +bm, but that doesn't work.  I know another solution involves calling exec 2&gt; /dev/null, but is that reliable? How do I reset it back so that I can continue to see stderr?
120770
The output of the above command when passed through echo is:  # echo systemctl\ {restart,status}\ sshd\; systemctl restart sshd; systemctl status sshd;   Even if I paste the output to the terminal, the command works. But when I try to directly run the command, I get:  # systemctl\ {restart,status}\ sshd\; bash: systemctl restart sshd;: command not found...   I have two questions..   What exactly is this method of substitution and expansion called? (So that I can research it and learn more about it and how to use it properly).  What did I do wrong here? Why doesn't it work?
50563
I am currently looking ways to suppress error command in Linux, in particular, the command cp.   I do:   root@ubuntu:~$ cp /srv/ftp/201*/wha*/*.jj ~/. cp: cannot stat `/srv/ftp/201*/wha*/*.jj': No such file or directory   How do I suppress the error message that gets printed on the screen? I.e., I don't want to see this error message in my monitor.
39406
According to its documentation, bash waits until all commands in a pipeline have finished running before continuing     The shell waits for all commands in the pipeline to terminate before returning a value.   So why does the command yes | true finish immediately? Shouldn't the yes loop forever and cause the pipeline to never return?    And a subquestion: according to the , shell pipelines may choose to either return after the last command finishes or wait until all the commands finish. Do common shells have different behavior in this sense? Are there any shells where yes | true will loop forever?
24737
Lets say I have a loop in Bash:  for foo in `some-command` do    do-something $foo done   do-something is cpu bound and I have a nice shiny 4 core processor. I'd like to be able to run up to 4 do-something's at once.  The naive approach seems to be:  for foo in `some-command` do    do-something $foo &amp; done   This will run all do-somethings at once, but there are a couple downsides, mainly that do-something may also have some significant I/O which performing all at once might slow down a bit. The other problem is that this code block returns immediately, so no way to do other work when all the do-somethings are finished.  How would you write this loop so there are always X do-somethings running at once?
7780
I have a script which calls two commands:  long_running_command | print_progress   The long_running_command prints progress but I'm unhappy with it. I'm using print_progress to make it nicer (namely, I print the progress in a single line).  The problem: Connection a pipe to stdout also activates a 4K buffer, so the nice print program gets nothing ... nothing ... nothing ... a whole lot ... :)  How can I disable the 4K buffer for the long_running_command (no, I do not have the source)?
106029
I'm using Mac, and I'm trying to time the command execution.  If I do  time echo   it doesn't have any output  But If I do  time ls   it does give me the output of time function  Any idea why that happens?  Update: turns out it's cuz I'm using zsh, with oh-my-zsh installed. It works well in bash, but no output in zsh. Any idea why?
43301
I think it's something like  this: (Fedora14/bash)  #!/bin/bash  for i in {0..10..1}; do echo -e "$i"'\c' echo -e "\n\r" sleep 1 done   But it doesn't work. Purpose: like this, but without the "clear":   #!/bin/bash  for i in {0..10..1}; do echo -e "$i" sleep 1 clear done   So a counting script that doesn't deletes the whole screen to output +1 number, instead it only deletes the line, where the counting is, so that there could be ex.: a beatifull "progress bar"..
2226
I am looking for a way to get the output of a command when it is run from within a C++ program.  I have looked at using the system() function, but that will just execute a command. Here's an example of what I'm looking for:  std::string result = system("./some_command");   I need to run an arbitrary command and get its output. I've looked at , but I have not found anything that will give me what I need.
76879
I want to execute something in a linux shell under a few different conditions, and be able to output the execution time of each execution.  I know I could write a perl or python script that would do this, but is there a way I can do it in the shell? (which happens to be bash)
54667
I just wanted to ask whether there is any command which would work on common shells (bash, dash, kornshell)? It is supposed to check if the line variable contains any part of the path.  if [[ $line =~ "$PWD"$ ]] ;then