LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   shell script variable for OS? (https://www.linuxquestions.org/questions/programming-9/shell-script-variable-for-os-4175691668/)

mattdawolf 03-06-2021 09:49 AM

shell script variable for OS?
 
If I wanted to append a my hostname to a copied/tarred file, I'd use `hostname`

Is there an equivelant for printing the OS?

Keith Hedger 03-06-2021 09:52 AM

Code:

uname --help

mattdawolf 03-06-2021 02:13 PM

Greetings. Thank you for your response. How would I append that to a tar command, such as

tar -zcvf ~/path/to/file-`hostname`-`date +%Y%m%d`.tar.gz /etc

Keith Hedger 03-06-2021 02:48 PM

Exactly the same way as you attach the date command except use uname + whaterver options you want

mattdawolf 03-06-2021 04:15 PM

Got it. Thanks.

Keith Hedger 03-06-2021 05:08 PM

Don't forget to post your solution and mark the thread 'SOLVED' for others benifits


All times are GMT -5. The time now is 06:09 PM.