Add hostname to file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Add hostname to file
# 1  
Old 01-30-2015
Linux Add hostname to file

How can add stamp hostname to create new file, e. g.

Code:
user@machine $ touch file1-$(date +%Y-%m-%d_%H:%M:%S)

generate 

file1-2015-01-30_11:24:55

I wannt touch file with hotname file1-2015-01-30_11:24:55_machine,

Thanks you,
# 2  
Old 01-30-2015
Hello aav1307,

Could you please try following and let me know if this helps.
Code:
touch file1-$(date +%Y-%m-%d_%H:%M:%S)_`hostname`

Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
# 3  
Old 01-30-2015
$(hostname) (which is the same as `hostname`) or $HOSTNAME could by tried as well.

hth
This User Gave Thanks to sea For This Post:
# 4  
Old 01-30-2015
Nice

Thank you
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Hostname -f hostname: Unknown host

deleted (0 Replies)
Discussion started by: hce
0 Replies

2. Shell Programming and Scripting

Hostname lookup and create text file

I have a list of hostnames in a txt file . I need to do nslookup or other command on linux and get the ip address and if you dont find an ip address then put 0.0.0.0 instead in the output text file along with the hostname. So input host1 host2 host2.dd.ddd.net Output host1,... (2 Replies)
Discussion started by: gubbu
2 Replies

3. Shell Programming and Scripting

Fetch ipaddress and hostname from host file.

hello guys, I have a query ,I am looking for a unix command using awk and grep that help me fetching a particular ip address and hostname from the host file.........?????? (3 Replies)
Discussion started by: Pawan Ramnani
3 Replies

4. Shell Programming and Scripting

How to extract hostname from file using awk?

Hi iam having file with below lines of text pun-ras-bng-mhs-01#cont bsnl.in enk-ras-bng-cse-01#cont bsnl.in how to extract the host name and store in a variable and to print output using awk command output will be HOSTNAME pun-ras-bng-mhs-01 enk-ras-bng-cse-01 Tnx in advance. (13 Replies)
Discussion started by: surender reddy
13 Replies

5. UNIX for Advanced & Expert Users

AIX - Sendmail - add hostname to subject of outgoing mail

Hello, I'm configuring sendmail on an AIX 7.1 server (bos.net.tcp.client 7.1.1.15). I've gotten sendmail to send mail through our Novell GroupWise server, so that mail from a user on the server appears to come from their GroupWise account, and replies to the email would go to their GroupWise... (0 Replies)
Discussion started by: eyebeam
0 Replies

6. Emergency UNIX and Linux Support

HP UX - ILO Console hostname different than Machine Hostname...

Hi All, So we added a new HP-UX 11.31 machine. Copied OS via Ignite-UX (DVD)over from this machine called machine_a. It was supposed to be named machine_c. And it is when you log in...however when I'm in the ILO console before logging in, it says: It should say: What gives? And how do... (4 Replies)
Discussion started by: zixzix01
4 Replies

7. Solaris

Confused with entries in /etc/hostname.<interface> file...

Hi.. Every one, I have servers installed with solaris 10.We have configured our servers for IPMP and we have respective entries in /etc/hostname.<interface> for every physical interface. for example one of the file contains : # more /etc/hostname.ce6 super-ce6 netmask + broadcast + group... (3 Replies)
Discussion started by: Reboot
3 Replies

8. Shell Programming and Scripting

naming a file to hostname

I am running a script remotely to another client. after it runs it places the file in /tmp. I need the file in /tmp to be renamed to the local hostname. but when i set the variable it names the file to my local hostname. how do i fix that (4 Replies)
Discussion started by: deaconf19
4 Replies

9. UNIX for Dummies Questions & Answers

Solaris - unknown hostname - how can I change hostname?

Hello, I am new to Solaris. I am using stand alone Solaris 10.0 for test/study purpose and connecting to internet via an ADSL modem which has DHCP server. My Solaris is working on VMWare within winXP. My WinXP and Solaris connects to internet by the same ADSL modem via its DHCP at the same... (1 Reply)
Discussion started by: XNOR
1 Replies

10. Solaris

/etc/hostname.interface file

I recently brought up a second network interface adapter in my Solaris 8 box. I configured the /etc/hostname.interface (hostname.ce1 in this case) with the hostname of the new adapter. I then added that hostname to the /etc/hosts file. Problem is when I reboot the ce1 interface is plumbed, but... (1 Reply)
Discussion started by: ghuber
1 Replies
Login or Register to Ask a Question