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

GauravG
  • 19
  • 7

1 Answers1

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.

  • 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. – GauravG Aug 20 '20 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. – Gustavo Kawamoto Aug 20 '20 at 11:38
  • ok i got you @Gustavo thanks for your help – GauravG Aug 20 '20 at 11:40