Solved pull substring from string in bash
-
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
-
that's pretty good. Using cut would be another option. Not better, just an option.
-
@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.
-
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