% and & meanings
hello,
i have 2 questions .. i've seen that for bringing a program to the foreground, one should write simply fg 1 (1 is the number of the job) ... but for sending a job to the background, one should write fg %1 .. why ? what does % means here? my second questions, is what does & mean, when you write: 1>&2 (I'm trying that the stdout and sterr go to the same place) ... when i want the stdout to go to a file, a simply write 1> file , the same with the stderr, so what does it mean the & here? (1>%2) ? thanks, Eduardo Lidanski |
There is no need to post each question you have 3 different times in 3 different forums!
Read our rules you agreed to when registering: http://www.linuxquestions.org/rules.php |
yeah sorry! i didn't know ! i guess i didn't read the rules carefully, isn't gonna happen anymore!
sorry! |
I think it is 2>&1 and not 1>&2
|
are you sure? and what does the & mean?
|
To send a program to the background you can run the program followed by an apersand. Such as: "./configure &" to run the process in the background while you attend to other tasks.
|
yeah, but in the context 2>&1 ? that is, when you want the stout und sterr to be the same for the current command?
|
The question about foreground/background.
A program can be suspended using ctrl+z To take up execution in foreground type fg %1 To take up the execution in the background use bg %1 To the redirection question. Both 1>&2 and 2>&1 The numbers are called file handles. File handle 0 is standard input(stdin), 1 is standard output(stdout) and 2 is standard error(stderr). The redirection above says redirect stdout to file handle stderr. The & sign need to be there much like the $-sign in variables references in shell script. |
and why don't u write a & before the 1? i mean &1>&2 ? why only after the second number?
|
Good question. I don't have good explanation right now, but if I come across an answer I'll post it.
Both 1>&2 and 2>&1 work but they do different things First directs all output to where stderr ends up, which might be the system log. The other one makes the errors end up where stdout does, normally the screen. |
All times are GMT -5. The time now is 06:33 PM. |