I am trying to use part of the
hostname
output in Linux and use it in a file using sed
. For example, I am using this command as
hostname | tail -c 4
which shows me output as last 4 numbers and then use this output and substitute it with another text inside a file.
Assuming part of the hostname
command shows with tail -c 4
option, "1234" How can I take it this further and use it to replace it with another file? I can do this manually by:
hostname | tail -c 4 ; sed -i 's/oldtext/1234/g' filename.txt
but not sure how can I achieve this with script? Any ideas?
Asked by geek12
(13 rep)
Nov 4, 2022, 08:44 PM
Last activity: Jun 28, 2024, 10:38 AM
Last activity: Jun 28, 2024, 10:38 AM