I have a file which several lines, let's say:
server_file.txt:
[main]
server1 param1 param2 param3
server2 param1 param2 param3
I want to take the first value of last column to compose a filename within an expect
script so that the filename is: server2_030417T124700, where 030417T124700 is the current date when the file was created.
I have been able to achieve the date part with these lines:
#!/usr/bin/expect -f
log_file ./log/post.log
<some_code>
system mv ./log/post.log ./log/post_[clock format [clock seconds] -format {%Y%m%dT%H%M%S}].log
But where I have "post_" I would like to have "server2" based on last line of server_file.txt
I have tried to do it by using a variable that executes the bash command tail -1 server_file.txt | awk '{print $1}'
with no success and I think it is possible to do it without using a bash command.