Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 02 07:59
    NariyasuHeseri opened #1717
  • Nov 29 03:15
    likan999 commented #1716
  • Nov 29 03:10
    likan999 commented #1716
  • Nov 29 03:10
    likan999 commented #1716
  • Nov 29 03:09
    likan999 synchronize #1716
  • Nov 29 02:53
    likan999 synchronize #1716
  • Nov 28 20:18
    likan999 synchronize #1716
  • Nov 28 20:17
    likan999 opened #1716
  • Nov 28 16:29
    cornfeedhobo commented #1714
  • Nov 27 01:30
    cornfeedhobo closed #1713
  • Nov 27 01:30
    cornfeedhobo commented #1713
  • Nov 26 17:13

    NoahGorny on master

    Update atomic.theme.bash fixed… Merge pull request #1715 from l… (compare)

  • Nov 26 17:13
    NoahGorny closed #1715
  • Nov 26 14:20
    NoahGorny commented #1715
  • Nov 26 14:15
    lfelipe1501 commented #1713
  • Nov 26 14:11
    lfelipe1501 opened #1715
  • Nov 26 13:50
    lfelipe1501 commented #1713
  • Nov 26 12:04
    egvimo opened #1714
  • Nov 26 10:29
    egvimo commented #1713
  • Nov 26 10:27
    egvimo opened #1713
jquiterio
@jquiterio
i think it will give you the version
Marc Guilera
@marcguilera
yup! thanks :)
jquiterio
@jquiterio
"([0-9]{1,}.)+[0-9]{1,}"
lol
when you paste '"([0-9]{1,}.)+[0-9]{1,}"' on gitter it remove the '\' :)
so yeah grep -Eo "([0-9]{1,}\.)+[0-9]{1,}"
Marc Guilera
@marcguilera
is it possible to stop looking if grep already finds a match?
jquiterio
@jquiterio
just add a condition
while read line; do if echo $line | grep -Eo "([0-9]{1,}\.)+[0-9]{1,}"; then break; fi ; done < testfil.txt
Herb Stahl
@ghstahl
Is there a bash expert here interested in a small challenge.
Cody Mikol
@codymikol
Whatcha got
Herb Stahl
@ghstahl
ok
#!/bin/sh -l
die () {
    echo >&2 "$@"
    echo "die"
    exit 1
}
# This works
# az group create --name "rg-terraform-lionking" --location "eastus2" --tags "a=b" "c=a dog"

REQUIRED_ARGS=3
[ "$#" -eq $REQUIRED_ARGS ] || die "$REQUIRED_ARGS argument required, $# provided"
 bash --version

resource_group_name=$1  
location=$2
tags=$3

echo "resource_group_name:" $resource_group_name
echo "location:"            $location
echo "tags"                 $tags

az account show 

SUBSCRIPTION_ID="$(az account show --query id -o tsv)"
echo 'SUBSCRIPTION_ID: '$SUBSCRIPTION_ID
echo "==== Creating Resource Group: $resource_group_name in Location: $location"



az group create --name "$resource_group_name" --location "$location"  --tags "${tags}"
I need to pass in tags so that it works when calling the az group cli
I have run out of google searches
notice the space in "a dog"
--tags "a=b" "c=a dog"
jquiterio
@jquiterio
"c='a dog'"?
Herb Stahl
@ghstahl

I need to pass in the entire --tags to the scipt

tags='"a=b" "c=a dog"'
bash ./az-create-group.sh rg-terraform-lionking eastus2 "${tags}"

output.

resource_group_name: rg-terraform-lionking
location: eastus2
tags "a=b" "c=a dog"
...
"tags": {
    "\"a": "b\" \"c=a dog\""
  },

it gets interpreted as jibrish when I pass that into az group

# This works
# az group create --name "rg-terraform-lionking" --location "eastus2" --tags "a=b" "c=a dog"

output

"tags": {
    "a": "b",
    "c": "a dog"
  },
I can't change the az cli
jquiterio
@jquiterio
i don’t get your question its it’s already solved. anyway this should work: tags='a="b" c="a dog"' or tags="a=b c='a dog'", then —tags $tags
jquiterio
@jquiterio
or tags=("a=b" "c=a dog") than —tags --tags "${tags[@]}"
Herb Stahl
@ghstahl
let me try that
Herb Stahl
@ghstahl
so none of those worked

They all seem ok when I

echo "tags"                 $tags

from inside my script, but when I then pass them along to "az group create" they fail to go into that cli properly

jquiterio
@jquiterio
\"${tags[@]}\" if az want "" on tags explicitly
Herb Stahl
@ghstahl

so tell me this?
calling the following directly

az group create --name "rg-terraform-lionking" --location "eastus2" --tags "a=b" "c=a dog"

works.
For reference I simply echoed what my script is going to do.

echo az group create --name "$resource_group_name" --location "$location"  --tags "${tags}"

Output:

az group create --name rg-terraform-lionking --location eastus2 --tags "a=b" "c=a dog"

its the same thing being passed into tags. However from inside my script those arguments to --tags get jacked up

Herb Stahl
@ghstahl
so az lets the following happen, I only put "" on there because of the space between "a dog"
--tags a=b c=d  # this is ok
--tags a=b c=a dog #not ok, goes in a c=a, and dog is separate
--tags a=b "c=a dog" # this is ok
jquiterio
@jquiterio
and \""a=b c=a dog"\" ?
Herb Stahl
@ghstahl

nope

tags=\""a=b c=a dog"\"
echo $tags
"a=b c=a dog"
bash ./az-create-group.sh rg-terraform-lionking eastus2 "${tags}"

gets interpreted by az as

 "tags": {
    "\"a": "b c=a dog\""
  },
jquiterio
@jquiterio
well, az is python
it means that it will probably do "k=v k=v".split(" ")
Herb Stahl
@ghstahl
What is confusing me is that if I can call az with working arguments to --tag from the command line, what can I do to do the same thing in my script. I would think that no matter what az is doing internally I should be able to repo a good call inside a sh
az seems to be parsing ok.
 az group create --name "rg-terraform-lionking" --tags "a=b" "c=a dog" --location eastus2
I put --location after --tags
jquiterio
@jquiterio
great :D
Herb Stahl
@ghstahl
great indeed
Vaibhav Shrivastava
@mishuvs
Can anyone help me with correcting this cron job: 30 8-21/4 * * * sleep ${RANDOM:0:2}m ; script.sh ?
I need to run script.sh every 4 hours with random delays from 10 to 99 minutes.
I tried it with a random logging script into a file, but it seems like the job is not running. Any kind of help or hints would help.
12annumishra17
@12annumishra17

Hey all .

How to use a rest API in my bash script. Can anybody guide ?

Micah Dameron
@chronaeon
@12annumishra17 what specifically are you trying to do? (code excerpts and/or API calls would help)
Micah Dameron
@chronaeon
I'm launching a daemon process and I want to enter an extra BASH command that will e-mail me if the process shuts down for any reason. Is there already a program in BASH to do this, or should I write my own?
CrystalX127
@CrystalX127
Hello would anybody mind checking out my Github repository which is scripted in bash: at this link : https://github.com/CrystalX127/Shield
And if anyone would like to star or share my repository I would be delighted!
domdom8
@domdom8
hi guys,
do we have a way to write a script that will let our application log out automatically when we shut-down laptop?
that is for purpose of logging out everything in case we forget it
Yuki Wise
@MonolithicMonk
In bash scripting, what does
export OIDC_RP_PROVIDER_ENDPOINT="${CONTROLLER_URL:-http://DOCKERHOST:5000}"
mean?
Specifically what does the ":-" mean in setting this environment variable?
jquiterio
@jquiterio
OR
or CONTROLLER_URL or http://DOCKERHOST:5000
i think
Sarah Eldorado
@aryared1_gitlab
how did you become advanced with bash? how can I start?