What's the difference in these two lines of code?

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

What's the difference in these two lines of code?

#1 Post by RSH »

Hi.

I hope anyone can tell me what is the difference (in functionality) between the two following code lines:

Code: Select all

cp -af /root/puppy-reference /tmp/root/

Code: Select all

cp -af /root/puppy-reference /tmp/root/ 2>/dev/null
Thanks

RSH
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#2 Post by sunburnt »

Hi RSH; 2> redirects the error output of the command.
/dev/null is a "black hole" that swallows whatever is sent to it.

Code from my AppPkg mount file:

Code: Select all

Etc=`find etc/* 2> /dev/null`
If there`s no etc dir. in the current dir., there`s no error output in a VT.

User avatar
matiasbatero
Posts: 60
Joined: Fri 12 Oct 2012, 01:27
Location: Mar del Plata, Argentina

#3 Post by matiasbatero »

2> /dev/null is very usefull when you wants to make a silent scripts.
Adding 2> /dev/null, you send the ouput error to the trash, and nothing is printed on your screen.

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#4 Post by don570 »

Code: Select all

cp -af /root/puppy-reference /tmp/root/  2>/tmp/error$$
I have found that funnelling the error
message to a file in /tmp is useful in studying whether
my partition is filled up. I do a 'grep' of /tmp/error$$
to see if there is text 'no space left' or whatever that error message is.


I used that technique in my pet packages 'Extract-pet' and 'Extract-debian'
to warn the user that there is not enough disk space to do extraction.

It works well with 'mv' command or 'mv -i' command I believe.

____________________________________________________

postfs1

#5 Post by postfs1 »

Maybe: request for a third-party programmatic option.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#6 Post by sunburnt »

I`ve always thought that copy and move should check target free space.
What`s the point in even beginning to copy if there`s not enough space?

Remembering the days of copying to a floppy only to have it fail at the end
because the darn thing has enough bad sectors that it won`t hold the data.

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#7 Post by RSH »

Hi.

Thanks to all for clearing this. I was a bit afraid to have left something out that would be necessary - in all of my programs. :lol:

RSH
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

Post Reply