IBM Community Hub

IBM Community Hub

The central place for general IBM discussions, knowledge sharing, and community updates. Explore our Topic Group List to find groups dedicated to individual IBM products and services.


#Other


#General(All)
 View Only
  • 1.  Looking for AIX regex cmdline/ksh scripting assistance.

    Posted 04/06/22 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 04/07/22 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 04/07/22 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
    ------------------------------