LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-09-2004, 02:44 PM   #1
jesus_edu
LQ Newbie
 
Registered: Mar 2004
Location: Darmstadt, Germany
Distribution: Suse 9.0
Posts: 29

Rep: Reputation: 15
% 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
 
Old 04-09-2004, 02:50 PM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 235Reputation: 235Reputation: 235
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
 
Old 04-09-2004, 02:51 PM   #3
jesus_edu
LQ Newbie
 
Registered: Mar 2004
Location: Darmstadt, Germany
Distribution: Suse 9.0
Posts: 29

Original Poster
Rep: Reputation: 15
yeah sorry! i didn't know ! i guess i didn't read the rules carefully, isn't gonna happen anymore!
sorry!
 
Old 04-09-2004, 03:23 PM   #4
dominant
Member
 
Registered: Jan 2004
Posts: 409

Rep: Reputation: 30
I think it is 2>&1 and not 1>&2
 
Old 04-11-2004, 02:55 AM   #5
jesus_edu
LQ Newbie
 
Registered: Mar 2004
Location: Darmstadt, Germany
Distribution: Suse 9.0
Posts: 29

Original Poster
Rep: Reputation: 15
are you sure? and what does the & mean?
 
Old 04-11-2004, 09:34 AM   #6
Poetics
Senior Member
 
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 1,181

Rep: Reputation: 49
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.
 
Old 04-12-2004, 03:25 PM   #7
jesus_edu
LQ Newbie
 
Registered: Mar 2004
Location: Darmstadt, Germany
Distribution: Suse 9.0
Posts: 29

Original Poster
Rep: Reputation: 15
yeah, but in the context 2>&1 ? that is, when you want the stout und sterr to be the same for the current command?
 
Old 04-12-2004, 05:31 PM   #8
ugge
Senior Member
 
Registered: Dec 2000
Location: Gothenburg, SWEDEN
Distribution: OpenSUSE 10.3
Posts: 1,028

Rep: Reputation: 45
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.
 
Old 04-12-2004, 05:39 PM   #9
jesus_edu
LQ Newbie
 
Registered: Mar 2004
Location: Darmstadt, Germany
Distribution: Suse 9.0
Posts: 29

Original Poster
Rep: Reputation: 15
and why don't u write a & before the 1? i mean &1>&2 ? why only after the second number?
 
Old 04-13-2004, 02:27 AM   #10
ugge
Senior Member
 
Registered: Dec 2000
Location: Gothenburg, SWEDEN
Distribution: OpenSUSE 10.3
Posts: 1,028

Rep: Reputation: 45
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Phục hồi dữ liệu bị mất???, cứ pollsite General 1 06-27-2005 12:39 PM
Directories and Meanings virtualme Linux - Newbie 1 03-24-2005 06:36 PM
ksysguard cpu meanings Hexane Linux - Newbie 1 01-20-2005 02:14 AM
% and & meanings jesus_edu Linux - Software 1 04-09-2004 02:46 PM
RPMTAG_REQUIREFLAGS meanings? eantoranz Programming 0 01-26-2004 10:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration