vendredi 5 novembre 2021

get environment variable from file or EV with awk to use it as EV

excuse me but I am a beginner and can't imagine how to solve my puzzle in Linux shell scripting.

I have the file. File with name /etc/hostname or environment variable $HOSTNAME in my case in this file is wroten RxPower-1 or TiPower-1

How I can get the first part RxPower or TiPower to use it later as an environment variable. I try to use awk but without success. Sorry for my bad English but this is not my mother language.

awk -F"-" '{if ($1=="RxPower") mm=$1;else mm=TiPower}' /etc/hostname

thank you Advance for your help !!

Aucun commentaire:

Enregistrer un commentaire