If you want to run a bash command from within a bash script, you can simply run them as follows,
Example 1: Simple command with no argument
#!/bin/bash
whoami
Output:
Example 2: Simple command with arguments
#!/bin/bash
whoami
Output:

Example 3: Storing Command Output to Variable
#!/bin/bash
date_today=$(date +"%Y-%m-%d %H:%M:%S")
echo $date_today
Output:
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!