0
{ echo ' ' ;echo ' IP : ' ;ip route get 8.8.8.8 | cut -d' ' -f7,8 | tr -d 'src' ;echo ' ' ;dmidecode -t bios | grep -iw 'Version' ;echo ' ' ;} 

the output of above command mentioned is:

IP : 10.0.0.1

 Version: 1.8 

but i want to allign it properly example below:

IP:10.0.0.1|Version:1.8

kindly help this is an urgent request. Thanks in Advance

2
  • You mean you need the output to be IP:$YOUR_IP|Version:$BIOS_VERSION? Commented Aug 20, 2020 at 11:18
  • yes,i need same as you mentioned Commented Aug 20, 2020 at 11:21

1 Answer 1

0

This might do the trick:

echo "'IP:$(ip route get 8.8.8.8 | grep '\<via\>' | awk '{print $7}')|Version:$(dmidecode -t bios | grep -iw Version | awk '{print $2}')'" 

Note that it's not considering that ip route get 8.8.8.8 | grep '\<via\>' or dmidecode -t bios | grep -iw Version might return more than one line.

2
  • your command is working fine when i am running as a command but in expect script giving error ```set XYZ "{ echo "'IP:$(ip route get 8.8.8.8 | awk '{print $7}')|Version:$(dmidecode -t bios | grep -iw Version | awk '{print $2}')"} >/tmp/Version_info_$NOW.log_$host.csv" i am storing the output in a file. Commented Aug 20, 2020 at 11:33
  • I couldn't get why you need the set XYZ. Isn't running the echo "..." > /your/file.csv enough? Probably you're having issues because the quotes aren't escaped. Commented Aug 20, 2020 at 11:38

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.