I have a script that connects to an FTP server and while doing so prints out a load of junk.
Is there a way to 'mute' the ouput of the script, similar to windows @echoff
? I saw on another question very similar to mine, not the same though that you could use scriptname >/dev/null
. When I put this in my program, obviously replacing scriptname
with the name of the script, I got a command not found
error message.
Does anyone have any idea why this might be happening.
If you mean you want to redirect all output to /dev/null
from within the script , rather than when you execute the script, you can do this:
#!/bin/bash
echo Hi
and run that, like this
./script
then do this
#!/bin/bash
exec 1> /dev/null
echo Hi
and run it again exactly the same way, and see that the output is discarded.
You wouldn't put that in your program, but rather, would use it when calling your program. On the command line:
$ scriptname >/dev/null
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.