Posted on August 11, 2019 at 11:52 am
Do you need to get the output of a program in a variable in Bash?
There are two simple ways to achieve that:
Or alternatively you can use $(), i.e:
Remember to not put spaces before or after the = operator.
If you need to capture also error messages use 2>&1:
var=$(./run.sh params 2>&1)
- PHP Notice: Undefined offset: 1 (Array)
- How to Sleep/Wait/Pause on a NodeJs Function
- How to Run a NodeJs Script
- How to Install a Module/Package/Library in NodeJs
- NodeJs Request.Get Example with Error Handling
- NodeJs HTTPS.Get Example with Error Handling
- How to Find PHP.ini Location
- How to Enable Display of Errors in PHP
- Detect a failing hard-disk on a Linux server
- Certbot.errors.CertStorageError: expected to be a symlink
- Example hard-disk error logs on a Linux server
- Certbot renew error: Account at does not exist.
- Suspicious online shops from email@example.com
- Nginx Rewrite Rule to Add Slash to The End of Any URL
- Compress Word, Excel and PowerPoint Office Documents
- Download OpenVPN 2.4.7 and TAP-Windows