ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    pull substring from string in bash

    Scheduled Pinned Locked Moved Solved IT Discussion
    bashscriptingasterisk
    4 Posts 2 Posters 547 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • JaredBuschJ
      JaredBusch
      last edited by

      I have a working solution, but I'm not a master bash expert. Just a guy that uses it a lot.

      Is there a better way to to what I am doing?
      This is the source data.

            Jared Busch (Local/103@from-queue/n from hint:103@ext-local) (ringinuse enabled) (dynamic) (Not in use) has taken no calls yet
            Test_Extension (Local/121@from-queue/n from hint:121@ext-local) (ringinuse enabled) (Not in use) has taken no calls yet
            T46S - Demo 1 (Local/118@from-queue/n from hint:118@ext-local) (ringinuse enabled) (Not in use) has taken no calls yet
      

      I need this part: Local/103@from-queue/n

      I am getting it currently, like this: grep -o Local.*/n

      Full sample:

      [jbusch@pbx ~]$ rasterisk -x 'queue show 150' | grep -o Local.*/n
      Local/103@from-queue/n
      Local/121@from-queue/n
      Local/118@from-queue/n
      
      1 Reply Last reply Reply Quote 0
      • scottalanmillerS
        scottalanmiller
        last edited by

        that's pretty good. Using cut would be another option. Not better, just an option.

        JaredBuschJ 1 Reply Last reply Reply Quote 0
        • JaredBuschJ
          JaredBusch @scottalanmiller
          last edited by

          @scottalanmiller said in pull substring from string in bash:

          that's pretty good. Using cut would be another option. Not better, just an option.

          It's been running in script for a year to unpause queue agents. but i'm thinking about expanding it. so before I do that, I anted to make sure it was decent as is.

          1 Reply Last reply Reply Quote 0
          • JaredBuschJ
            JaredBusch
            last edited by JaredBusch

            said script

            [jbusch@pbx ~]$ cat unpause_all.sh 
            #!/bin/sh
            set -e 
            
            rasterisk -x "queue show ${1}" | grep paused | grep -o Local.*/n | while read -r member
            do
                rasterisk -x "queue unpause member ${member} queue ${1}"
            done
            
            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post