0

I need help. I have this shell script that will output the hdd status, but the variable $disk is not read in the echo to show result.

 disk="sda1"
 echo -n $(df -hl | grep '$disk' | awk ' {percent+=$5;} END{print percent}'| column -t ):

1 Answer 1

2

In bash, variables are not expanded when put inside single quotes. Use double quotes:

echo -n $(df -hl | grep "$disk")
Sign up to request clarification or add additional context in comments.

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.