If I run this command in a script it doesn't produce output except header from the ps
:
# Taken from Advanced Bash Usage on youtube:
echo "$(echo "$(echo "$(echo "$(ps wwf -s $$)")")")"
This is the output:
$./testing.bash
PID TTY STAT TIME COMMAND
but here it is run in a terminal which produces the expected output:
$echo "$(echo "$(echo "$(echo "$(ps wwf -s $$)")")")"
PID TTY STAT TIME COMMAND
18289 pts/4 Ss+ 0:00 /bin/bash
17917 pts/4 S+ 0:00 \_ /bin/bash
17918 pts/4 S+ 0:00 \_ /bin/bash
17919 pts/4 S+ 0:00 \_ /bin/bash
17920 pts/4 S+ 0:00 \_ /bin/bash
17921 pts/4 R+ 0:00 \_ ps wwf -s 18289
QUESTION:
Can you explain the difference and show me the right way to do this?
I've tried a lot of things and searched google for 4 hours, if you need I can list what I tried but I don't think that's relevant here.
$echo $SHELL
/bin/bash
and:
$head -1 testing.bash
#!/bin/bash