Is this going to be visible in the process listing if the below line is executed from a command line or a shell script

bash -c "echo $password"


i just need to do echo $password from within bash on a command line or inside bash shell script

is there any test i can do to check such visiblity. i was just trying this but i wasn't able to see it in the process listing with ps -ef | grep testscript


while (( i < 100 ))
sleep 1
echo $$
echo hello

Just force it to use the builtin:

builtin echo foo

If echo is not a builtin, this will fail.

  • Thanks @Chris one doubt..is this going to be valid for linux only ? or will it work inside shells other than bash?
    – munish
    May 6 '13 at 7:30
  • @munish builtin is not POSIX, but is supported in most modern shells (bash, zsh, most implementations of ksh).
    – Chris Down
    May 6 '13 at 7:37

The arguments to a builtin will never show up in any ps output, because the builtin is not a separate program with its own command line. All modern shells (except some highly stripped-down configurations of BusyBox), including all bash versions, have echo built in.

Note that if you're calling bash -c "echo $password", then the password will show up for everyone to see, because it's embedded in the command that you run with bash. Calling a shell just to call its echo command is pointless, so hopefully you aren't doing that.

It's ok to put the password in an environment variable, if you need to pass it to a different process. Unlike command line arguments, environment variables are not exposed to other users under Linux and most other unices.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.