Pattern matching with date-like substrings
Is there a simple way to look for date-like patterns in strings, in my case YYYYMMDD?
abcd20230822efgh -> yes
19850102abcd -> yes
ab123445678cde -> no
My current Implementation is rather rudimentary and I wonder whether there is a more efficient way. First I get rid of everything in the string besides the numbers. Then I pick a 8 element wide window and test it for a valid date. Then I shift the window 1 element further and test again. This is repeated until a valid date is found or the window reaches the end of the string.
It works but it feels pretty clunky.
https://redd.it/17olrsr
@r_bash
Is there a simple way to look for date-like patterns in strings, in my case YYYYMMDD?
abcd20230822efgh -> yes
19850102abcd -> yes
ab123445678cde -> no
My current Implementation is rather rudimentary and I wonder whether there is a more efficient way. First I get rid of everything in the string besides the numbers. Then I pick a 8 element wide window and test it for a valid date. Then I shift the window 1 element further and test again. This is repeated until a valid date is found or the window reaches the end of the string.
It works but it feels pretty clunky.
https://redd.it/17olrsr
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Looking for proper path with noscript
I have a noscript which requires sudo. I setup it up to run using a user service / timer, and that part executes fine.
However, as soon as the noscript is ran (as the user), I get thrown:
sudo[389308]: pam_unix(sudo:auth): auth could not identify password for [username]
MyService[389309]: sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
I assume my noscript is having issues with not having the sudo password.
I've looked online, and people are suggesting creating a .passwd file and sticking the password in there with chmod 400, however, that seems extremely unsecure.
What are my options for being able to safely pass the sudo password to bash using something like cached credentials?
The noscript needs sudo, and I've tried running the noscript as a user service. I also tried a system service globally, but it also has an issue with needing root's password.
​
https://redd.it/17on7ih
@r_bash
I have a noscript which requires sudo. I setup it up to run using a user service / timer, and that part executes fine.
However, as soon as the noscript is ran (as the user), I get thrown:
sudo[389308]: pam_unix(sudo:auth): auth could not identify password for [username]
MyService[389309]: sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
I assume my noscript is having issues with not having the sudo password.
I've looked online, and people are suggesting creating a .passwd file and sticking the password in there with chmod 400, however, that seems extremely unsecure.
What are my options for being able to safely pass the sudo password to bash using something like cached credentials?
The noscript needs sudo, and I've tried running the noscript as a user service. I also tried a system service globally, but it also has an issue with needing root's password.
​
https://redd.it/17on7ih
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Help with bash parser
Hey guys! Well, I'll be direct, I'm developing a game (text adventure) in Shell Bash, I have some good experience with the language but not with programming games. My question is, how can I make a parser with (verb and noun) for my game? It will have around 30 rooms.
What I'm trying to implement is for example (pick up the torch) (drop the sword) and also (go north). Could you give me some light?
I am literally lost. I know that shell noscript is not the best language for this, but it is evolving in the language
I did something like this, would that be the way?
function VERB()
{
\# Only verb here
case verb in
take) NOUN ;;
drop) NOUN ;;
*) echo "$userInput WHY?"
esac
}
while true; do
read -rep "> " verb noun
VERB
done
https://redd.it/17p6uc0
@r_bash
Hey guys! Well, I'll be direct, I'm developing a game (text adventure) in Shell Bash, I have some good experience with the language but not with programming games. My question is, how can I make a parser with (verb and noun) for my game? It will have around 30 rooms.
What I'm trying to implement is for example (pick up the torch) (drop the sword) and also (go north). Could you give me some light?
I am literally lost. I know that shell noscript is not the best language for this, but it is evolving in the language
I did something like this, would that be the way?
function VERB()
{
\# Only verb here
case verb in
take) NOUN ;;
drop) NOUN ;;
*) echo "$userInput WHY?"
esac
}
while true; do
read -rep "> " verb noun
VERB
done
https://redd.it/17p6uc0
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Looking for bash guide
I’m still a newb so if I’m not asking correctly .. then please help.
So I’ve been tinker with fedora LDXE for a bit and I want to customize my terminal ..
I have a few books and have read a few articles .. everything points me to playing with the .bashrc file (don’t worry VM so I’m breaking lots of things purposely)
Anyways I have two questions to start:
First- my terminal works fine .. I can change my preferences in the file menu …but my .bashrc is pretty much blank .. no PS1 section or Color section like some of the tutorials point out - why is that?!
Second - all the books and online bash manual I read really only talk about changing my prompt .. but I see some people getting really intricate with Color’s .. where can I find the information .. or what language do I need to learn for the Color’s .. I can’t find any info on it?
https://redd.it/17phbi5
@r_bash
I’m still a newb so if I’m not asking correctly .. then please help.
So I’ve been tinker with fedora LDXE for a bit and I want to customize my terminal ..
I have a few books and have read a few articles .. everything points me to playing with the .bashrc file (don’t worry VM so I’m breaking lots of things purposely)
Anyways I have two questions to start:
First- my terminal works fine .. I can change my preferences in the file menu …but my .bashrc is pretty much blank .. no PS1 section or Color section like some of the tutorials point out - why is that?!
Second - all the books and online bash manual I read really only talk about changing my prompt .. but I see some people getting really intricate with Color’s .. where can I find the information .. or what language do I need to learn for the Color’s .. I can’t find any info on it?
https://redd.it/17phbi5
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Error with bash noscript. Integer expression expected.
Does any one know what I am doing wrong? This is the first bash noscript I have ever written. It's for a class. The noscript is supposed to generate random numbers. So when you run the noscript you type how many numbers you want it to generate in the argument. I thought maybe the issue was I needed $ in front of count and it may still be, but when I tried adding it in, then the noscript wouldn't run at all.
line 12: [: count: integer expression expected
1 numGen=$1 #number of numbers being generated
2 min=$2 #minimum number
3 max=$3 #maximum number
4 average=0 #average of the numbers generated
5 smallest=32768 #smallest number generated
6 largest=0 #largest number generated
7
8
9 if $# -eq 1
10 then
11 count=0
12 while count -lt $numGen
13 do
14 randNum=$RANDOM
15 echo $randNum >> randomNumbers$numGen.txt
16 average=$(($average + $randNum))
17
18 if $randNum -gt $largest
19 then
20 largest=$randNum
21 fi
22
23 if $randNum -lt $smallest
24 then
25 smallest=$randNum
26 fi
27 done
​
https://redd.it/17pi4cq
@r_bash
Does any one know what I am doing wrong? This is the first bash noscript I have ever written. It's for a class. The noscript is supposed to generate random numbers. So when you run the noscript you type how many numbers you want it to generate in the argument. I thought maybe the issue was I needed $ in front of count and it may still be, but when I tried adding it in, then the noscript wouldn't run at all.
line 12: [: count: integer expression expected
1 numGen=$1 #number of numbers being generated
2 min=$2 #minimum number
3 max=$3 #maximum number
4 average=0 #average of the numbers generated
5 smallest=32768 #smallest number generated
6 largest=0 #largest number generated
7
8
9 if $# -eq 1
10 then
11 count=0
12 while count -lt $numGen
13 do
14 randNum=$RANDOM
15 echo $randNum >> randomNumbers$numGen.txt
16 average=$(($average + $randNum))
17
18 if $randNum -gt $largest
19 then
20 largest=$randNum
21 fi
22
23 if $randNum -lt $smallest
24 then
25 smallest=$randNum
26 fi
27 done
​
https://redd.it/17pi4cq
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Pulseaudio is soo bad,worst software ever created, all these permissions etc.
https://redd.it/17pgeq5
@r_bash
https://redd.it/17pgeq5
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Improving my bash?
I've finished a 20 hr course on udemy on bash. My linux experience is around 3 months. And this is the noscript that I wrote for clearing logs by traversing the directory.
#!/bin/bash
givenpath=/home/techyman/glassfish4/glassfish/domains
excludedfolder="x"
function clearlog() {
cd "$each"
echo "$PWD"
find . -mtime +"$1" -name "*.log" -exec rm -f {} \;
#echo "$2"
#echo "$1"
}
for each in "$givenpath"/; do
if [ "$each" = "$given_path/$excluded_folder" ]; then
echo "$each"
#echo "This is x"
#echo "Do nothing"
continue
else
#echo "this is not x"
#echo "$each"
#case statement goes here
case $each in
a)
echo "This is a"
clearlog 7 "$each"
;;
*b)
echo "This is b"
clearlog 4 "$each"
;;
c)
echo "This is c"
clear_log 5 "$each"
;;
d)
echo "This is d"
clearlog 6 "$each"
;;
*e)
echo "This is e"
clearlog 8 "$each"
;;
esac
fi
done
Please review. Am I doing enough?
https://redd.it/17pxpn1
@r_bash
I've finished a 20 hr course on udemy on bash. My linux experience is around 3 months. And this is the noscript that I wrote for clearing logs by traversing the directory.
#!/bin/bash
givenpath=/home/techyman/glassfish4/glassfish/domains
excludedfolder="x"
function clearlog() {
cd "$each"
echo "$PWD"
find . -mtime +"$1" -name "*.log" -exec rm -f {} \;
#echo "$2"
#echo "$1"
}
for each in "$givenpath"/; do
if [ "$each" = "$given_path/$excluded_folder" ]; then
echo "$each"
#echo "This is x"
#echo "Do nothing"
continue
else
#echo "this is not x"
#echo "$each"
#case statement goes here
case $each in
a)
echo "This is a"
clearlog 7 "$each"
;;
*b)
echo "This is b"
clearlog 4 "$each"
;;
c)
echo "This is c"
clear_log 5 "$each"
;;
d)
echo "This is d"
clearlog 6 "$each"
;;
*e)
echo "This is e"
clearlog 8 "$each"
;;
esac
fi
done
Please review. Am I doing enough?
https://redd.it/17pxpn1
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
grep with perl regex should NOT highlight/match the comma, but it does
Hello people,
​
I have the following code, that should highlight any non-ascii characters in my german txt files (so that i can easy replace/remove it in a next step). That works with one exception:, it also highlights all the commas ',' and i don't know how to get rid of that. The code [1\]:
grep --color='auto' -P -n "[\\x80-\\x81,\\x83-\\xC3,\\xC5-\\xD5,\\xD7-\\xDB,\\xDD-\\xE3,\\xE5-\\xF5,\\xF7-\\xFB,\\xFD-\\xFF\]" inputfile.txt
Output lists lines that contains comma ',' but that is not wanted. Does anybody see the mistake ? I am looking at the example now for 3 hours but i can't get it.
​
[1\] (original code source): https://stackoverflow.com/questions/3001177/how-do-i-grep-for-all-non-ascii-characters
Greets
muh
https://redd.it/17q6y9n
@r_bash
Hello people,
​
I have the following code, that should highlight any non-ascii characters in my german txt files (so that i can easy replace/remove it in a next step). That works with one exception:, it also highlights all the commas ',' and i don't know how to get rid of that. The code [1\]:
grep --color='auto' -P -n "[\\x80-\\x81,\\x83-\\xC3,\\xC5-\\xD5,\\xD7-\\xDB,\\xDD-\\xE3,\\xE5-\\xF5,\\xF7-\\xFB,\\xFD-\\xFF\]" inputfile.txt
Output lists lines that contains comma ',' but that is not wanted. Does anybody see the mistake ? I am looking at the example now for 3 hours but i can't get it.
​
[1\] (original code source): https://stackoverflow.com/questions/3001177/how-do-i-grep-for-all-non-ascii-characters
Greets
muh
https://redd.it/17q6y9n
@r_bash
Stack Overflow
How do I grep for all non-ASCII characters?
I have several very large XML files and I'm trying to find the lines that contain non-ASCII characters. I've tried the following:
grep -e "[\x{00FF}-\x{FFFF}]" file.xml
But this returns...
grep -e "[\x{00FF}-\x{FFFF}]" file.xml
But this returns...
Is Bash more powerful than Powershell ? and How good is your Bash compared to Powershell or vice versa ?
Is Bash more powerful than Powershell ? and How good is your Bash compared to Powershell or vice versa ? please don't start to include python in your analysis of bash vs powershell because if you include a programming language like python we have to include C# with powershell etc So what's your opinion of Bash do you feel powershell is more powerful and more modern with object oriented nature and pipeline and all the rest around it ? or you feel windows isn't just made to be managed that way compared to a linux text based command and architecture as a whole ?
Do you feel the intricacies of the operating system matters less and less by the day (in the eye of a pure sysadmin view etc not of a cloud engineer/devops) since everything is moving to Infrastructure as code or inside Kubernetest clusters inside the cloud or serverless configurations etc or the future will be just noscripting in Bash/Powershell ? or virtual desktop like MS want to do with Azure for mostly everything
https://redd.it/17r45fa
@r_bash
Is Bash more powerful than Powershell ? and How good is your Bash compared to Powershell or vice versa ? please don't start to include python in your analysis of bash vs powershell because if you include a programming language like python we have to include C# with powershell etc So what's your opinion of Bash do you feel powershell is more powerful and more modern with object oriented nature and pipeline and all the rest around it ? or you feel windows isn't just made to be managed that way compared to a linux text based command and architecture as a whole ?
Do you feel the intricacies of the operating system matters less and less by the day (in the eye of a pure sysadmin view etc not of a cloud engineer/devops) since everything is moving to Infrastructure as code or inside Kubernetest clusters inside the cloud or serverless configurations etc or the future will be just noscripting in Bash/Powershell ? or virtual desktop like MS want to do with Azure for mostly everything
https://redd.it/17r45fa
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
How can I get a clean output from echo, without hidden characters?
Hi there,
I am working with lua and bash, and trying to set a variable in lua from a bash command, but this is not working. When I set the variable manually works, so my guess is that there are hidden characters (maybe encoding characters).
This is my line:
local vim.g.kubernetes_cluster = vim.fn.system('echo -n "$(kubectl config current-context 2>/dev/null)"')
So the command bash would be
echo -n "$(kubectl config current-context 2>/dev/null)"
Any advice is welcome! Thanks!
https://redd.it/17r7a91
@r_bash
Hi there,
I am working with lua and bash, and trying to set a variable in lua from a bash command, but this is not working. When I set the variable manually works, so my guess is that there are hidden characters (maybe encoding characters).
This is my line:
local vim.g.kubernetes_cluster = vim.fn.system('echo -n "$(kubectl config current-context 2>/dev/null)"')
So the command bash would be
echo -n "$(kubectl config current-context 2>/dev/null)"
Any advice is welcome! Thanks!
https://redd.it/17r7a91
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Short PWD
I've created a program for presenting the current working directory within the width of the terminal. This can be used in the shell prompts, like bash, zsh, fish, etc. to maintain their beautiful appearance.
Download here: GitHub or AUR
https://i.redd.it/dvw1n5zjaazb1.gif
https://redd.it/17r8m16
@r_bash
I've created a program for presenting the current working directory within the width of the terminal. This can be used in the shell prompts, like bash, zsh, fish, etc. to maintain their beautiful appearance.
Download here: GitHub or AUR
https://i.redd.it/dvw1n5zjaazb1.gif
https://redd.it/17r8m16
@r_bash
GitHub
GitHub - Andrew-Flame/spwd: Program for displaying the current working directory in the shell prompt
Program for displaying the current working directory in the shell prompt - GitHub - Andrew-Flame/spwd: Program for displaying the current working directory in the shell prompt
How to find the youngest file in dir1 and then find all files younger than that in dir2, recursively?
Like the noscript says. I am hard-pressed to add more details without also adding confusion.
If the youngest file in dir1 and all its subdirs is from Nov 1 00:00:00, I want to find all files in dir2 (and all its subdirs) which are younger than that.
Is there a quick oneliner which could solve this?
Solutions for finding the youngest file are available. To use the modification date of this file for another search seems to be a lot more tricky, though.
https://redd.it/17rarw1
@r_bash
Like the noscript says. I am hard-pressed to add more details without also adding confusion.
If the youngest file in dir1 and all its subdirs is from Nov 1 00:00:00, I want to find all files in dir2 (and all its subdirs) which are younger than that.
Is there a quick oneliner which could solve this?
Solutions for finding the youngest file are available. To use the modification date of this file for another search seems to be a lot more tricky, though.
https://redd.it/17rarw1
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Grep/Sed from hit until 2nd newline
Hello,
Im fairly new to linux and bash/noscripting in general. Now i need to search through a large text file, and i want to filter out relevant information. So far i've been using: grep with the -A and -B flags, both taking a number and then including the lines Before and After the hit with grep. Now i have the following challenge:
I want to search the text file, and i want to include a few set amount of lines before the hit (-A flag) but i want to include a varying amount of lines after the hit, namely everything until the 2nd newline. How do i go about this?
Example:
Text.txt is the following:
Apple
Banana
Error
Delta
Echo
Romeo
More stuff
BlaBla
=====================
​
I want to execute the command, something like grep -B 1 'Error' ??SomeMoreFlags/Hacks here??
And in return i expect:
Banana
Error
Delta
Echo
​
Is anyone able to help me? I've heard people mention sed/cat/grep/regex matching and i feel this should be possible, but im having trouble finding the solution.
​
​
https://redd.it/17rihm0
@r_bash
Hello,
Im fairly new to linux and bash/noscripting in general. Now i need to search through a large text file, and i want to filter out relevant information. So far i've been using: grep with the -A and -B flags, both taking a number and then including the lines Before and After the hit with grep. Now i have the following challenge:
I want to search the text file, and i want to include a few set amount of lines before the hit (-A flag) but i want to include a varying amount of lines after the hit, namely everything until the 2nd newline. How do i go about this?
Example:
Text.txt is the following:
Apple
Banana
Error
Delta
Echo
Romeo
More stuff
BlaBla
=====================
​
I want to execute the command, something like grep -B 1 'Error' ??SomeMoreFlags/Hacks here??
And in return i expect:
Banana
Error
Delta
Echo
​
Is anyone able to help me? I've heard people mention sed/cat/grep/regex matching and i feel this should be possible, but im having trouble finding the solution.
​
​
https://redd.it/17rihm0
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
wc, piping & stdout
Upon learning the
~/project$ wc -w kittyipsum1.txt
332 kittyipsum1.txt
VS.
~/project$ cat kittyipsum1.txt | wc -w
332
​
https://redd.it/17rmcyl
@r_bash
Upon learning the
wc command, I've seen a couple of ways to extract data based on the option(s) passed in. Is there anyway to get result of the second example with how the command is written in the first? I'm confused why the second example just prints the number for words without the filename.~/project$ wc -w kittyipsum1.txt
332 kittyipsum1.txt
VS.
~/project$ cat kittyipsum1.txt | wc -w
332
​
https://redd.it/17rmcyl
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
JQ merge changes from one json to another
I have two JSON files
Source
{
"version": 122,
"GeneralData":
{
"disableBaseDamage": false,
"disableContainerDamage": false,
"disableRespawnDialog": false,
"disableRespawnInUnconsciousness": false
},
"PlayerData":
{
"disablePersonalLight": false,
"StaminaData":
{
"sprintStaminaModifierErc": 1.0,
"sprintStaminaModifierCro": 1.0,
"staminaWeightLimitThreshold": 6000.0,
"staminaMax": 100.0,
"staminaKgToStaminaPercentPenalty": 1.75,
"staminaMinCap": 5.0,
"sprintSwimmingStaminaModifier": 1.0,
"sprintLadderStaminaModifier": 1.0,
"meleeStaminaModifier": 1.0,
"obstacleTraversalStaminaModifier": 1.0,
"holdBreathStaminaModifier": 1.0
},
"ShockHandlingData":
{
"shockRefillSpeedConscious": 5.0,
"shockRefillSpeedUnconscious": 1.0,
"allowRefillSpeedModifier": true
},
"MovementData":
{
"timeToStrafeJog": 0.1,
"rotationSpeedJog": 0.3,
"timeToSprint": 0.45,
"timeToStrafeSprint": 0.3,
"rotationSpeedSprint": 0.15,
"allowStaminaAffectInertia": true
},
"DrowningData":
{
"staminaDepletionSpeed": 10.0,
"healthDepletionSpeed": 10.0,
"shockDepletionSpeed": 10.0
}
},
"WorldsData":
{
"lightingConfig": 1,
"objectSpawnersArr": ,
"environmentMinTemps": -3.0, -2.0, 0.0, 4.0, 9.0, 14.0, 18.0, 17.0, 12.0, 7.0, 4.0, 0.0,
"environmentMaxTemps": 3.0, 5.0, 7.0, 14.0, 19.0, 24.0, 26.0, 25.0, 21.0, 16.0, 10.0, 5.0,
"wetnessWeightModifiers": 1.0, 1.0, 1.33, 1.66, 2.0
},
"BaseBuildingData":
{
"HologramData":
{
"disableIsCollidingBBoxCheck": false,
"disableIsCollidingPlayerCheck": false,
"disableIsClippingRoofCheck": false,
"disableIsBaseViableCheck": false,
"disableIsCollidingGPlotCheck": false,
"disableIsCollidingAngleCheck": false,
"disableIsPlacementPermittedCheck": false,
"disableHeightPlacementCheck": false,
"disableIsUnderwaterCheck": false,
"disableIsInTerrainCheck": false,
"disallowedTypesInUnderground": "FenceKit","TerritoryFlagKit","WatchtowerKit"
},
"ConstructionData":
{
"disablePerformRoofCheck": false,
"disableIsCollidingCheck": false,
"disableDistanceCheck": false
}
},
"UIData":
{
"use3DMap": false,
"HitIndicationData":
{
"hitDirectionOverrideEnabled": false,
"hitDirectionBehaviour": 1,
"hitDirectionStyle": 0,
"hitDirectionIndicatorColorStr": "0xffbb0a1e",
"hitDirectionMaxDuration": 2.0,
"hitDirectionBreakPointRelative": 0.2,
"hitDirectionScatter": 10.0,
"hitIndicationPostProcessEnabled": true
}
},
"MapData":
{
"ignoreMapOwnership": false,
"ignoreNavItemsOwnership": false,
"displayPlayerPosition": false,
"displayNavInfo": true
}
}
and changes
{
"version": 122,
"GeneralData":
{
"disableBaseDamage": false,
"disableContainerDamage": false,
"disableRespawnDialog": false,
"disableRespawnInUnconsciousness": false
},
"PlayerData":
{
"disablePersonalLight": false,
"StaminaData":
{
"sprintStaminaModifierErc": 1.0,
"sprintStaminaModifierCro": 1.0,
"staminaWeightLimitThreshold": 6000.0,
"staminaMax": 100.0,
"staminaKgToStaminaPercentPenalty": 1.75,
"staminaMinCap": 5.0,
"sprintSwimmingStaminaModifier": 1.0,
"sprintLadderStaminaModifier": 1.0,
"meleeStaminaModifier": 1.0,
"obstacleTraversalStaminaModifier": 1.0,
"holdBreathStaminaModifier": 1.0
},
"ShockHandlingData":
{
"shockRefillSpeedConscious": 5.0,
"shockRefillSpeedUnconscious": 1.0,
"allowRefillSpeedModifier": true
},
I have two JSON files
Source
{
"version": 122,
"GeneralData":
{
"disableBaseDamage": false,
"disableContainerDamage": false,
"disableRespawnDialog": false,
"disableRespawnInUnconsciousness": false
},
"PlayerData":
{
"disablePersonalLight": false,
"StaminaData":
{
"sprintStaminaModifierErc": 1.0,
"sprintStaminaModifierCro": 1.0,
"staminaWeightLimitThreshold": 6000.0,
"staminaMax": 100.0,
"staminaKgToStaminaPercentPenalty": 1.75,
"staminaMinCap": 5.0,
"sprintSwimmingStaminaModifier": 1.0,
"sprintLadderStaminaModifier": 1.0,
"meleeStaminaModifier": 1.0,
"obstacleTraversalStaminaModifier": 1.0,
"holdBreathStaminaModifier": 1.0
},
"ShockHandlingData":
{
"shockRefillSpeedConscious": 5.0,
"shockRefillSpeedUnconscious": 1.0,
"allowRefillSpeedModifier": true
},
"MovementData":
{
"timeToStrafeJog": 0.1,
"rotationSpeedJog": 0.3,
"timeToSprint": 0.45,
"timeToStrafeSprint": 0.3,
"rotationSpeedSprint": 0.15,
"allowStaminaAffectInertia": true
},
"DrowningData":
{
"staminaDepletionSpeed": 10.0,
"healthDepletionSpeed": 10.0,
"shockDepletionSpeed": 10.0
}
},
"WorldsData":
{
"lightingConfig": 1,
"objectSpawnersArr": ,
"environmentMinTemps": -3.0, -2.0, 0.0, 4.0, 9.0, 14.0, 18.0, 17.0, 12.0, 7.0, 4.0, 0.0,
"environmentMaxTemps": 3.0, 5.0, 7.0, 14.0, 19.0, 24.0, 26.0, 25.0, 21.0, 16.0, 10.0, 5.0,
"wetnessWeightModifiers": 1.0, 1.0, 1.33, 1.66, 2.0
},
"BaseBuildingData":
{
"HologramData":
{
"disableIsCollidingBBoxCheck": false,
"disableIsCollidingPlayerCheck": false,
"disableIsClippingRoofCheck": false,
"disableIsBaseViableCheck": false,
"disableIsCollidingGPlotCheck": false,
"disableIsCollidingAngleCheck": false,
"disableIsPlacementPermittedCheck": false,
"disableHeightPlacementCheck": false,
"disableIsUnderwaterCheck": false,
"disableIsInTerrainCheck": false,
"disallowedTypesInUnderground": "FenceKit","TerritoryFlagKit","WatchtowerKit"
},
"ConstructionData":
{
"disablePerformRoofCheck": false,
"disableIsCollidingCheck": false,
"disableDistanceCheck": false
}
},
"UIData":
{
"use3DMap": false,
"HitIndicationData":
{
"hitDirectionOverrideEnabled": false,
"hitDirectionBehaviour": 1,
"hitDirectionStyle": 0,
"hitDirectionIndicatorColorStr": "0xffbb0a1e",
"hitDirectionMaxDuration": 2.0,
"hitDirectionBreakPointRelative": 0.2,
"hitDirectionScatter": 10.0,
"hitIndicationPostProcessEnabled": true
}
},
"MapData":
{
"ignoreMapOwnership": false,
"ignoreNavItemsOwnership": false,
"displayPlayerPosition": false,
"displayNavInfo": true
}
}
and changes
{
"version": 122,
"GeneralData":
{
"disableBaseDamage": false,
"disableContainerDamage": false,
"disableRespawnDialog": false,
"disableRespawnInUnconsciousness": false
},
"PlayerData":
{
"disablePersonalLight": false,
"StaminaData":
{
"sprintStaminaModifierErc": 1.0,
"sprintStaminaModifierCro": 1.0,
"staminaWeightLimitThreshold": 6000.0,
"staminaMax": 100.0,
"staminaKgToStaminaPercentPenalty": 1.75,
"staminaMinCap": 5.0,
"sprintSwimmingStaminaModifier": 1.0,
"sprintLadderStaminaModifier": 1.0,
"meleeStaminaModifier": 1.0,
"obstacleTraversalStaminaModifier": 1.0,
"holdBreathStaminaModifier": 1.0
},
"ShockHandlingData":
{
"shockRefillSpeedConscious": 5.0,
"shockRefillSpeedUnconscious": 1.0,
"allowRefillSpeedModifier": true
},
"MovementData":
{
"timeToStrafeJog": 0.1,
"rotationSpeedJog": 0.3,
"timeToSprint": 0.45,
"timeToStrafeSprint": 0.3,
"rotationSpeedSprint": 0.15,
"allowStaminaAffectInertia": true
},
"DrowningData":
{
"staminaDepletionSpeed": 10.0,
"healthDepletionSpeed": 10.0,
"shockDepletionSpeed": 10.0
}
},
"WorldsData":
{
"lightingConfig": 1,
"objectSpawnersArr": ,
"environmentMinTemps": -3.0, -2.0, 0.0, 4.0, 9.0, 14.0, 18.0, 17.0, 12.0, 7.0, 4.0, 0.0,
"environmentMaxTemps": 3.0, 5.0, 7.0, 14.0, 19.0, 24.0, 26.0, 25.0, 21.0, 16.0, 10.0, 5.0,
"wetnessWeightModifiers": 1.0, 1.0, 1.33, 1.66, 2.0
},
"BaseBuildingData":
{
"HologramData":
{
"disableIsCollidingBBoxCheck": true,
"disableIsCollidingPlayerCheck": true,
"disableIsClippingRoofCheck": true,
"disableIsBaseViableCheck": true,
"disableIsCollidingGPlotCheck": true,
"disableIsCollidingAngleCheck": true,
"disableIsPlacementPermittedCheck": true,
"disableHeightPlacementCheck": true,
"disableIsUnderwaterCheck": true,
"disableIsInTerrainCheck": true,
"disallowedTypesInUnderground": "FenceKit","TerritoryFlagKit","WatchtowerKit"
},
"ConstructionData":
{
"disablePerformRoofCheck": true,
"disableIsCollidingCheck": true,
"disableDistanceCheck": true
}
},
"UIData":
{
"use3DMap": false,
"HitIndicationData":
{
"hitDirectionOverrideEnabled": false,
"hitDirectionBehaviour": 1,
"hitDirectionStyle": 0,
"hitDirectionIndicatorColorStr": "0xffbb0a1e",
"hitDirectionMaxDuration": 2.0,
"hitDirectionBreakPointRelative": 0.2,
"hitDirectionScatter": 10.0,
"hitIndicationPostProcessEnabled": true
}
},
"MapData":
{
"ignoreMapOwnership": true,
"ignoreNavItemsOwnership": true,
"displayPlayerPosition": true,
"displayNavInfo": true
}
}
If I run
jq -c --slurpfile f2 cfggameplaychanges.json '. + $f2[0]' cfggameplaysource.json
I get
{
"version": 122,
"GeneralData": {
"disableBaseDamage": false,
"disableContainerDamage": false,
"disableRespawnDialog": false,
"disableRespawnInUnconsciousness": false
},
"PlayerData": {
"disablePersonalLight": false,
"StaminaData": {
"sprintStaminaModifierErc": 1,
"sprintStaminaModifierCro": 1,
"staminaWeightLimitThreshold": 6000,
"staminaMax": 100,
"staminaKgToStaminaPercentPenalty": 1.75,
"staminaMinCap": 5,
"sprintSwimmingStaminaModifier": 1,
"sprintLadderStaminaModifier": 1,
"meleeStaminaModifier": 1,
"obstacleTraversalStaminaModifier": 1,
"holdBreathStaminaModifier": 1
},
"ShockHandlingData": {
"shockRefillSpeedConscious": 5,
"shockRefillSpeedUnconscious": 1,
"allowRefillSpeedModifier": true
},
"MovementData": {
"timeToStrafeJog": 0.1,
"rotationSpeedJog": 0.3,
"timeToSprint": 0.45,
"timeToStrafeSprint": 0.3,
"rotationSpeedSprint": 0.15,
"allowStaminaAffectInertia": true
},
"DrowningData": {
"staminaDepletionSpeed": 10,
"healthDepletionSpeed": 10,
"shockDepletionSpeed": 10
}
},
"WorldsData": {
"lightingConfig": 1,
"objectSpawnersArr": ,
"environmentMinTemps":
-3,
-2,
0,
4,
9,
14,
18,
17,
12,
7,
4,
0
,
"environmentMaxTemps":
3,
5,
7,
14,
19,
24,
26,
25,
21,
16,
10,
5
,
{
"timeToStrafeJog": 0.1,
"rotationSpeedJog": 0.3,
"timeToSprint": 0.45,
"timeToStrafeSprint": 0.3,
"rotationSpeedSprint": 0.15,
"allowStaminaAffectInertia": true
},
"DrowningData":
{
"staminaDepletionSpeed": 10.0,
"healthDepletionSpeed": 10.0,
"shockDepletionSpeed": 10.0
}
},
"WorldsData":
{
"lightingConfig": 1,
"objectSpawnersArr": ,
"environmentMinTemps": -3.0, -2.0, 0.0, 4.0, 9.0, 14.0, 18.0, 17.0, 12.0, 7.0, 4.0, 0.0,
"environmentMaxTemps": 3.0, 5.0, 7.0, 14.0, 19.0, 24.0, 26.0, 25.0, 21.0, 16.0, 10.0, 5.0,
"wetnessWeightModifiers": 1.0, 1.0, 1.33, 1.66, 2.0
},
"BaseBuildingData":
{
"HologramData":
{
"disableIsCollidingBBoxCheck": true,
"disableIsCollidingPlayerCheck": true,
"disableIsClippingRoofCheck": true,
"disableIsBaseViableCheck": true,
"disableIsCollidingGPlotCheck": true,
"disableIsCollidingAngleCheck": true,
"disableIsPlacementPermittedCheck": true,
"disableHeightPlacementCheck": true,
"disableIsUnderwaterCheck": true,
"disableIsInTerrainCheck": true,
"disallowedTypesInUnderground": "FenceKit","TerritoryFlagKit","WatchtowerKit"
},
"ConstructionData":
{
"disablePerformRoofCheck": true,
"disableIsCollidingCheck": true,
"disableDistanceCheck": true
}
},
"UIData":
{
"use3DMap": false,
"HitIndicationData":
{
"hitDirectionOverrideEnabled": false,
"hitDirectionBehaviour": 1,
"hitDirectionStyle": 0,
"hitDirectionIndicatorColorStr": "0xffbb0a1e",
"hitDirectionMaxDuration": 2.0,
"hitDirectionBreakPointRelative": 0.2,
"hitDirectionScatter": 10.0,
"hitIndicationPostProcessEnabled": true
}
},
"MapData":
{
"ignoreMapOwnership": true,
"ignoreNavItemsOwnership": true,
"displayPlayerPosition": true,
"displayNavInfo": true
}
}
If I run
jq -c --slurpfile f2 cfggameplaychanges.json '. + $f2[0]' cfggameplaysource.json
I get
{
"version": 122,
"GeneralData": {
"disableBaseDamage": false,
"disableContainerDamage": false,
"disableRespawnDialog": false,
"disableRespawnInUnconsciousness": false
},
"PlayerData": {
"disablePersonalLight": false,
"StaminaData": {
"sprintStaminaModifierErc": 1,
"sprintStaminaModifierCro": 1,
"staminaWeightLimitThreshold": 6000,
"staminaMax": 100,
"staminaKgToStaminaPercentPenalty": 1.75,
"staminaMinCap": 5,
"sprintSwimmingStaminaModifier": 1,
"sprintLadderStaminaModifier": 1,
"meleeStaminaModifier": 1,
"obstacleTraversalStaminaModifier": 1,
"holdBreathStaminaModifier": 1
},
"ShockHandlingData": {
"shockRefillSpeedConscious": 5,
"shockRefillSpeedUnconscious": 1,
"allowRefillSpeedModifier": true
},
"MovementData": {
"timeToStrafeJog": 0.1,
"rotationSpeedJog": 0.3,
"timeToSprint": 0.45,
"timeToStrafeSprint": 0.3,
"rotationSpeedSprint": 0.15,
"allowStaminaAffectInertia": true
},
"DrowningData": {
"staminaDepletionSpeed": 10,
"healthDepletionSpeed": 10,
"shockDepletionSpeed": 10
}
},
"WorldsData": {
"lightingConfig": 1,
"objectSpawnersArr": ,
"environmentMinTemps":
-3,
-2,
0,
4,
9,
14,
18,
17,
12,
7,
4,
0
,
"environmentMaxTemps":
3,
5,
7,
14,
19,
24,
26,
25,
21,
16,
10,
5
,
"wetnessWeightModifiers":
1,
1,
1.33,
1.66,
2
},
"BaseBuildingData": {
"HologramData": {
"disableIsCollidingBBoxCheck": true,
"disableIsCollidingPlayerCheck": true,
"disableIsClippingRoofCheck": true,
"disableIsBaseViableCheck": true,
"disableIsCollidingGPlotCheck": true,
"disableIsCollidingAngleCheck": true,
"disableIsPlacementPermittedCheck": true,
"disableHeightPlacementCheck": true,
"disableIsUnderwaterCheck": true,
"disableIsInTerrainCheck": true,
"disallowedTypesInUnderground":
"FenceKit",
"TerritoryFlagKit",
"WatchtowerKit"
},
"ConstructionData": {
"disablePerformRoofCheck": true,
"disableIsCollidingCheck": true,
"disableDistanceCheck": true
}
},
"UIData": {
"use3DMap": false,
"HitIndicationData": {
"hitDirectionOverrideEnabled": false,
"hitDirectionBehaviour": 1,
"hitDirectionStyle": 0,
"hitDirectionIndicatorColorStr": "0xffbb0a1e",
"hitDirectionMaxDuration": 2,
"hitDirectionBreakPointRelative": 0.2,
"hitDirectionScatter": 10,
"hitIndicationPostProcessEnabled": true
}
},
"MapData": {
"ignoreMapOwnership": true,
"ignoreNavItemsOwnership": true,
"displayPlayerPosition": true,
"displayNavInfo": true
}
}
Which is sooooo close to what I need. How do I turn these
"wetnessWeightModifiers":
1,
1,
1.33,
1.66,
2
into this
"wetnessWeightModifiers": 1,1,1.33,1.66,2
and preferably keep the decimals from the original "1.0,1.0,1.33,1.66,2.0" thank you so much for your assistance in advance.
https://redd.it/17rpl3z
@r_bash
1,
1,
1.33,
1.66,
2
},
"BaseBuildingData": {
"HologramData": {
"disableIsCollidingBBoxCheck": true,
"disableIsCollidingPlayerCheck": true,
"disableIsClippingRoofCheck": true,
"disableIsBaseViableCheck": true,
"disableIsCollidingGPlotCheck": true,
"disableIsCollidingAngleCheck": true,
"disableIsPlacementPermittedCheck": true,
"disableHeightPlacementCheck": true,
"disableIsUnderwaterCheck": true,
"disableIsInTerrainCheck": true,
"disallowedTypesInUnderground":
"FenceKit",
"TerritoryFlagKit",
"WatchtowerKit"
},
"ConstructionData": {
"disablePerformRoofCheck": true,
"disableIsCollidingCheck": true,
"disableDistanceCheck": true
}
},
"UIData": {
"use3DMap": false,
"HitIndicationData": {
"hitDirectionOverrideEnabled": false,
"hitDirectionBehaviour": 1,
"hitDirectionStyle": 0,
"hitDirectionIndicatorColorStr": "0xffbb0a1e",
"hitDirectionMaxDuration": 2,
"hitDirectionBreakPointRelative": 0.2,
"hitDirectionScatter": 10,
"hitIndicationPostProcessEnabled": true
}
},
"MapData": {
"ignoreMapOwnership": true,
"ignoreNavItemsOwnership": true,
"displayPlayerPosition": true,
"displayNavInfo": true
}
}
Which is sooooo close to what I need. How do I turn these
"wetnessWeightModifiers":
1,
1,
1.33,
1.66,
2
into this
"wetnessWeightModifiers": 1,1,1.33,1.66,2
and preferably keep the decimals from the original "1.0,1.0,1.33,1.66,2.0" thank you so much for your assistance in advance.
https://redd.it/17rpl3z
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Issue making JSON string
So I need to make a pure JSON string using a variable, and I'm bashing (no pun intended) my head against the wall trying to get the result I want:
The desired result looks like this:
'{"app":"app-version.tar","db":"db-version.tar"}'
The variable I have would contain the version info (so like, $VERSION), and I CANNOT get a proper JSON out of something like
'{"app":"app-'$VERSION'.tar","db":"db-'$VERSION'.tar"}'
Anyone able to help?
Edit: I also need to echo the EXACT string being generated at some earlier point as well, for making sure everything is correct.
https://redd.it/17rpjsh
@r_bash
So I need to make a pure JSON string using a variable, and I'm bashing (no pun intended) my head against the wall trying to get the result I want:
The desired result looks like this:
'{"app":"app-version.tar","db":"db-version.tar"}'
The variable I have would contain the version info (so like, $VERSION), and I CANNOT get a proper JSON out of something like
'{"app":"app-'$VERSION'.tar","db":"db-'$VERSION'.tar"}'
Anyone able to help?
Edit: I also need to echo the EXACT string being generated at some earlier point as well, for making sure everything is correct.
https://redd.it/17rpjsh
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community