IBM TechXchange Group

TechXchange Group

Your hub for all things community! Ask questions, connect with fellow members, get the support you need, and stay informed with the latest updates.


#Other
#TechXchangePresenter

 View Only
  • 1.  Looking for AIX regex cmdline/ksh scripting assistance.

    Posted Wed April 06, 2022 09:11 AM
    Hello People, 

    Completely unsure if I'm going to offend by asking this in here, so if I'm barking up the wrong tree, be gentle please.

    I'm diving into AIX for the first time and need to script up extracting some info from various commands. But AIX has me a bit stumped. 

    dc1aix13556:/root#lsattr -El sys0 -a modelname
    modelname IBM,8408-44E Machine name False​


    As you can see, the above cmd returns me the model information. From this I just want to extract the 'IBM'.

    In Linux, I would just grep what I want with perl regex-fu, retain that, and discard the rest. But AIX doesn't want to play nice. I can't figure out how to match, retain, and discard the rest.

    If someone could either assist or just point me in the right direction please, I would be grateful.  



    #aix #regex ​​​

    ------------------------------
    Kyle Lange
    ------------------------------


  • 2.  RE: Looking for AIX regex cmdline/ksh scripting assistance.
    Best Answer

    Posted Thu April 07, 2022 03:23 AM
    Assuming I understood your requirement correctly, this is what I would try:

    lsattr -El sys0 -a modelname -F value | sed -e 's/,.*//'

    This will only output the value of the modelname parameter, then sed cuts off everything after the comma.

    ------------------------------
    Zaki Jääskeläinen
    ------------------------------



  • 3.  RE: Looking for AIX regex cmdline/ksh scripting assistance.

    Posted Thu April 07, 2022 03:59 AM
    <Insert your deity here> Damnit!

    I knew there had to be an easier way than what I was coming up with. 

    Thank you Zaki.

    ------------------------------
    Kyle Lange
    ------------------------------