Forum Discussion
Mahi
Cirrus
Nov 14, 2019Setting $hostname variable
Hello, I want to setup the environment variable referring the hostname of the current device and use it in multiple commands such as tcpdump as follows. tcpdump -nni 0.0 -s0 -w /var/tmp/$hostn...
Simon_Blakely
Employee
Nov 14, 2019Mostly, it looks to be like you want a bash alias (for things like date or time).
But you can also do this with bash command substitution which might be better as you need no local configuration (creating aliases or environment variables)
tcpdump -nni 0.0 -s0 -w /var/tmp/$(/bin/hostname)_$(date +%Y-%m-%d)_$(date +%H:%M).pcap
tcpdump -nni 0.0 -s0 -w /var/tmp/localhost.localdomain_2019-11-14_15:48.pcap
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects