LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   % and & meanings (https://www.linuxquestions.org/questions/linux-newbie-8/and-and-meanings-168240/)

jesus_edu 04-09-2004 02:44 PM

% 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

trickykid 04-09-2004 02:50 PM

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

jesus_edu 04-09-2004 02:51 PM

yeah sorry! i didn't know ! i guess i didn't read the rules carefully, isn't gonna happen anymore!
sorry!

dominant 04-09-2004 03:23 PM

I think it is 2>&1 and not 1>&2

jesus_edu 04-11-2004 02:55 AM

are you sure? and what does the & mean?

Poetics 04-11-2004 09:34 AM

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.

jesus_edu 04-12-2004 03:25 PM

yeah, but in the context 2>&1 ? that is, when you want the stout und sterr to be the same for the current command?

ugge 04-12-2004 05:31 PM

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.

jesus_edu 04-12-2004 05:39 PM

and why don't u write a & before the 1? i mean &1>&2 ? why only after the second number?

ugge 04-13-2004 02:27 AM

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.