I'm working on Mac OS Sierra Shell.
Here is an example:
#!/bin/bash
contenu=`df`
echo ${contenu}
When I execute this shell, I can see the result of df
.
However, when I try to print the first line of history
, I can just see an empty line.
#!/bin/bash
contenu=`history | head -1`
echo ${contenu}
I've also executed the same command on the terminal and it worked very well.
user$ history | head -1
When I execute the command above, I can see what I'm waiting for. For example:
161 ls -l