Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 12 Nov 2019, 17:50
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Command to copy a directory to console and save files?
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [9 Posts]  
Author Message
arivas_2005

Joined: 25 Feb 2007
Posts: 210

PostPosted: Fri 10 May 2019, 23:53    Post subject:  Command to copy a directory to console and save files?  

regards
a favor Confused

give me a command to copy a whole directory (with its subdirectories)
but, (three things) a) I want to see the output in console and,
b) save the normal output in a file output.txt and,
c) errors in another file errors.txt
I know I can use cp -Rrfv but I have problems using the stdin and stdout and even more redirect to a console
(i use google traslators spanish to english)
my thanks!
Back to top
View user's profile Send private message 
fabrice_035


Joined: 28 Apr 2014
Posts: 644
Location: Bretagne / France

PostPosted: Sat 11 May 2019, 02:20    Post subject:  

Hello

G! < shell output error >

https://askubuntu.com/questions/625224/how-to-redirect-stderr-to-a-file


Code:


There are two main output streams in Linux (and other OSs), standard output (stdout) and standard error (stderr). Error messages, like the ones you show, are printed to standard error. The classic redirection operator (command > file) only redirects standard output, so standard error is still shown on the terminal. To redirect stderr as well, you have a few choices:

    Redirect stdout to one file and stderr to another file:

    command > out 2>error

    Redirect stderr to stdout (&1), and then redirect stdout to a file:

    command >out 2>&1

    Redirect both to a file:

    command &> out



Edit :

Code:
command args 2>error.txt | tee -a normal.txt

Last edited by fabrice_035 on Sat 11 May 2019, 02:45; edited 2 times in total
Back to top
View user's profile Send private message 
s243a

Joined: 02 Sep 2014
Posts: 2144

PostPosted: Sat 11 May 2019, 02:41    Post subject:  

fabrice_035 wrote:
Hello

G! < shell output error >

https://askubuntu.com/questions/625224/how-to-redirect-stderr-to-a-file


Code:


There are two main output streams in Linux (and other OSs), standard output (stdout) and standard error (stderr). Error messages, like the ones you show, are printed to standard error. The classic redirection operator (command > file) only redirects standard output, so standard error is still shown on the terminal. To redirect stderr as well, you have a few choices:

    Redirect stdout to one file and stderr to another file:

    command > out 2>error

    Redirect stderr to stdout (&1), and then redirect stdout to a file:

    command >out 2>&1

    Redirect both to a file:

    command &> out



I think that the original poster wants the output to also go to the terminal so I think that you need to throw the "tee" command in there somewhere.
Back to top
View user's profile Send private message Visit poster's website 
fabrice_035


Joined: 28 Apr 2014
Posts: 644
Location: Bretagne / France

PostPosted: Sat 11 May 2019, 02:45    Post subject:  

you read my mind.
I was editing my message to complete it when you wrote your answer.
Shocked

_________________
xenialpup 7.5 / Linux Kernel: 4.4.95 / Window Manager: JWM v2.3.7
Back to top
View user's profile Send private message 
arivas_2005

Joined: 25 Feb 2007
Posts: 210

PostPosted: Sat 11 May 2019, 18:22    Post subject:  

thanks for the support.

with
Code:
command args 2>error.txt | tee -a normal.txt

I do not see all the way out (do not see the errors)

a) I need to see the entire output and at the same time pass it to a file

b)launch the command opening a console and inside the console see the total list and then send it to a file.

in my test [for a)] I only got to see the whole output.

here line
command args 2>&1
and the segment ' | tee -a error.txt ' here does not work.

but the command gets stuck and does not end
(I use google translate)
Thank you again
Back to top
View user's profile Send private message 
williams2

Joined: 14 Dec 2018
Posts: 190

PostPosted: Sat 11 May 2019, 19:16    Post subject:  

Code:
cd /tmp
rsync -av /tmp/a1/ /tmp/c1/ 2>&1 | tee all.txt
grep ^rsync all.txt > errors.txt
grep -v ^rsync all.txt > output.txt
Back to top
View user's profile Send private message 
Burunduk

Joined: 21 Aug 2011
Posts: 76

PostPosted: Mon 13 May 2019, 15:55    Post subject:  

Combining the snippets from this article:

Code:
exec 3>&1
{ command | tee -a output.log >&3; } 2>&1 | tee -a error.log
exec 3>&-


(Esto debería funcionar como se esperaba.)
Back to top
View user's profile Send private message 
s243a

Joined: 02 Sep 2014
Posts: 2144

PostPosted: Mon 13 May 2019, 15:58    Post subject:  

Burunduk wrote:
Combining the snippets from this article:

Code:
exec 3>&1
{ command | tee -a output.log >&3; } 2>&1 | tee -a error.log
exec 3>&-


(Esto debería funcionar como se esperaba.)


Thankyou Smile

This is very helpful in expanding what I can do with a pipe.

_________________
Find me on minds and on pearltrees.
Back to top
View user's profile Send private message Visit poster's website 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1925
Location: Japan

PostPosted: Mon 13 May 2019, 23:49    Post subject:  

Burunduk wrote:
Code:
exec 3>&1
{ command | tee -a output.log >&3; } 2>&1 | tee -a error.log
exec 3>&-

Hmmm...do we really need this extra pipe? This works for me as well:
Code:
{ command | tee -a output.txt >/dev/tty ;} 2>&1 | tee -a errors.txt
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [9 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0522s ][ Queries: 11 (0.0133s) ][ GZIP on ]