LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-06-2021, 09:49 AM   #1
mattdawolf
Member
 
Registered: Aug 2018
Posts: 34

Rep: Reputation: Disabled
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?
 
Old 03-06-2021, 09:52 AM   #2
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,148

Rep: Reputation: 855Reputation: 855Reputation: 855Reputation: 855Reputation: 855Reputation: 855Reputation: 855
Code:
uname --help
 
1 members found this post helpful.
Old 03-06-2021, 02:13 PM   #3
mattdawolf
Member
 
Registered: Aug 2018
Posts: 34

Original Poster
Rep: Reputation: Disabled
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
 
Old 03-06-2021, 02:48 PM   #4
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,148

Rep: Reputation: 855Reputation: 855Reputation: 855Reputation: 855Reputation: 855Reputation: 855Reputation: 855
Exactly the same way as you attach the date command except use uname + whaterver options you want
 
1 members found this post helpful.
Old 03-06-2021, 04:15 PM   #5
mattdawolf
Member
 
Registered: Aug 2018
Posts: 34

Original Poster
Rep: Reputation: Disabled
Got it. Thanks.
 
Old 03-06-2021, 05:08 PM   #6
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,148

Rep: Reputation: 855Reputation: 855Reputation: 855Reputation: 855Reputation: 855Reputation: 855Reputation: 855
Don't forget to post your solution and mark the thread 'SOLVED' for others benifits
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] set variable based on another variable - shell script ceantuco Linux - Newbie 8 03-14-2018 02:17 PM
[SOLVED] Get bc script variable into a bash script variable? 14hei Programming 6 02-26-2016 07:34 AM
pass variable from one shell script into another shell script xskycamefalling Programming 9 10-03-2009 01:45 AM
AWK a variable Ouptut to a new variable and using the new variable with the old one alertroshannow Linux - Newbie 4 02-16-2009 12:08 AM
how to set a variable in a script and have the variable still set after script termin john test Linux - Newbie 9 10-21-2008 05:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration