[SOLVED] Usage of /dev/null minus signs instead of greater-than signs
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
'wd' is a company proprietary software piece written in C. It's a process that monitors other proprietary programs written in C that reside in a Linux environment.
The command above restarts wd after an upgrade has been implemented.
I'm trying to understand how it works. One thing that baffles me is the use of minus signs /dev/null instead of greater than signs. Can anyone explain to me why they are used this way, or perhaps point me in the direction of a tutorial that explains it? Not having much luck searching on google.
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150
Rep:
'-s' command line switch, most progs understand -h,--help or -? to give a summary of options that can be passed to it.
'<','>' io redirection '<' get input from ( in your example /dev/null ) '>' send output to ( again /dev/null ), /dev/null can be thought of as a black hole nothing gets out once its gone in.
2>/dev/null - slightly more complex , send stream 2 to /dev/null, all programs start with 3 basic streams open for them 0,1 and 2 which are stdin stdout and stderr. so this command sends error messages ( from stream 2 ) to /dev/null
/usr1/vision/bin/wd </dev/null 2</dev/null >/dev/null 2>/dev/null
/usr1/vision/bin/wd is the program you executed
</dev/null the standard input is redirected, the data is coming from /dev/null (means no data at all).
2</dev/null I have no idea, but I think it is completely meaningless
>/dev/null the standard output is redirected to /dev/null that means all the messages will be dropped
2>/dev/null the standard error is redirected to /dev/null, all the error messages are dropped
& means the program will be executed in the background (shell will not wait for it)
most important here is the semicolon ";". This tells the interpeter (shell) That the commands end here and is to be executed. So you can read the command as this:
So start wd with the option s
after its done
start wd reading from stdin and stderr both inputs coming from /dev/null and we also redirect the output of wd into /dev/null on stdout and stderr whith everything put into background through the ampersand "&".
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.