#!/bin/bash dir='../../configs-backup/' name=$1 port=$(cat $dir$name.bak | grep interface | tail -n 1 | awk '{print $2}') echo "hostname: \"$name\"" > $name.yml echo "nb_ports: $port" >> $name.yml echo "interfaces:" >> $name.yml cat $dir$name.bak | grep interface -A 3 | less