3

When I run this command,

sudo htpasswd -b /home/reynolds/.htpasswd admin admin

I am getting output Updating password for user admin in terminal but I dont want to display that output. So I searched some in google and try with the following commands.

sudo htpasswd -b /home/reynolds/.htpasswd admin admin 2>&1
sudo htpasswd -b /home/reynolds/.htpasswd admin admin > /dev/null

But still I am getting that output in terminal.Please help to avoid displaying such output while running this command. Please advice me as I am a very beginner in shell scripting.

Thanks.

3 Answers 3

7
 > /dev/null

and normal output is suppressed but errors are still shown

follow the command with

 > /dev/null 2>&1

and everything, including errors is supressed

Sign up to request clarification or add additional context in comments.

Comments

2

Just do the following;

sudo htpasswd -b /home/reynolds/.htpasswd admin admin > /dev/null 2>&1

should hide everything!

Comments

2

The reason you are getting this error is that sudo only applies to the very first command in the argument list.

The way to get around this is to encapsulate your command like so, using bash as an example:

sudo bash -c "htpasswd -b /home/reynolds/.htpasswd admin admin 2>&1"

Just remember that this creates a new bash shell, so any relative paths will not work and make sure that any environment variables you rely on, etc. are all available as well.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.