Help with basic folder perms (beginner)
Hey !
Im kinda new to bash, and im having a pretty basic problem here.
I have a minecraft server that restart, calling start.sh on restart.
When my ssh user do a bash start.sh, it works fine.
However, when the server execute it itself, the first instructions dont execute.
I'm pretty certain its a permission problem, but i cant figure why, because it should be accessible by everyone (first pic), and somehow, when the server restarts, the perms change (second pic)
Here is the bash i execute.
rm -r ./world
sleep 3
unzip -o lobby.zip -d world
sleep 3
java -Xmx3G -jar paper.jar #This get executed anyway
(sorry if there is code blocs, i dont know how)
​
When user execute bash script
After restart
https://redd.it/17spxh4
@r_bash
A few common shell functions (cat, mktemp, wc -c, and sleep) re-implemented in pure bash
I re-implemented a few common shell functions (that dont bash builtins with equivalent functionality) in pure bash. Anyone else do this? Anyone have any to add?
My use case for these tends to be to use them as "backups" when I want a code to be able to run on an embedded machine that has bash but everything else is not guaranteed. i.e.,
type -p FUNC >&/dev/null || {
FUNC() {
...
}
}
Here are the re-implemented functions. Each has a quick test along with it to ensure it is working. The functionality is not always an exact match to the original (not all flags are implemented...just the core functionality). But, for what is implemented it should (I think) be a drop-in replacement.
mktemp() {
local tmpFile
# generate tempfile name, and repeat until we get one that doesnt exist.
tmpFile=/tmp/.tmp.${RANDOM}
while [ -f "$tmpFile" ]; do
tmpFile=/tmp/.tmp.${RANDOM}
done
# touch tmpfile then echo its path
touch "${tmpFile}"
echo "${tmpFile}"
}
# test mktemp
file="$(mktemp)"
[ -f "${file}" ] && echo "tmpfile exists" >&2
echo
cat() {
if [ -t 0 ] && [ $# == 0 ]; then
# no input
return
elif [ $# == 0 ]; then
# only stdin
printf '%s\n' "$(</proc/self/fd/0)"
elif [ -t 0 ]; then
# only function inputs
source <(printf 'echo '; printf '"$(<"%s")" ' "$@"; printf '\n')
else
# both stdin and function inputs. fork printing stdin.
{ printf '%s\n' "$(</proc/self/fd/0)" >&9 & } 9>&1
source <(printf 'echo '; printf '"$(<"%s")" ' "$@"; printf '\n')
fi
}
# test cat
printf '%s\n' hi bye > "${file}"
printf '%s\n' hola adios | cat "${file}"
echo
wc() {
# only char/byte count (-c flag) implemented
# check for no input case
[ -t 0 ] && [ $# == 0 ] && return
# make tmpfile
local tmpFile fd waitFlag
tmpFile="$(mktemp)"
(
waitFlag=false
# add stdin, if anything is there
[ -t 0 ] || {
if [ $# == 0 ]; then
cat >&${fd}
else
# if we also are adding files then fork adding stdin
waitFlag=true
{ cat <&9 >&${fd} & } 9<&0
fi
}
# add function inputs that are files
for nn in "$@"; do
[ -f "$nn" ] && echo "$(<"${nn}")" >&${fd}
done
# wait for forked cat of stdin (if needed)
${waitFlag} && wait
# get the current position of fd
read </proc/self/fdinfo/${fd}
echo "${REPLY##$'\t'}"
) {fd}>>"${tmpFile}"
# remove tmpfile
[[ -f "${tmpFile}" ]] && \rm -f "${tmpFile}"
}
# test wc
printf '%s\n' hola adios | wc "${file}"
echo
sleep() {
local dur
# get sleep duration. default to 1 if missing.invalid
[[ "$1" =~ ^[0-9]\.?0-9+$ ]] && dur="$1" || dur=1
(
# read from empty anonymous pipe with timeout
read -u ${fd} -t "$dur"
) {fd}<><(:)
}
# test sleep
echo "hi - ${EPOCHREALTIME}"
sleep 2
echo "bye - ${EPOCHREALTIME}"
echo
https://redd.it/17scg3v
@r_bash
remove "" char from filenames
Hi,
this might seem like a dumb question but I can't find a way to do this.
I have a folder with a bunch of files, some of them contain asterisks in their names (\). Is there a way to remove them ? (maybe with mv)
https://redd.it/17s2w0n
@r_bash
Back to being a little confused about quoting
Could some kind soul take look here and maybe improve it to be "good". In particular, why doesn't it work if I double quote the use of ${OPTS} ? I'm probably mixing up differnt bash styles as this was made from cut and paste of answers on SO for each bit.
​
>\#!/usr/bin/env bash
>
>\# Maintained in linux-config.org
>
>LOGFILE="${HOME}/rclone-bisync-$(date +"%Y_%m_%d_%I_%M_%p").log"
>
>OPTS="--log-file=${LOGFILE} --log-level INFO --checkers=16 --drive-pacer-min-sleep=10ms --resilient --links --ignore-listing-checksum --check-sync=false --tpslimit=10 --drive-chunk-size=256M --drive-use-trash=false --fast-list ${HOME}/cloud cloud:"
>
>if pgrep -x "rclone" > /dev/null
>
>then
>
>echo "rclone already running. Bye." >> "$LOGFILE"
>
>exit 0
>
>fi
>
>mv rclone-bisync*.log "$HOME/tmp" 2>/dev/null
>
>rclone bisync ${OPTS}
>
>retVal=$?
>
>if [ $retVal -ne 0 \]; then
>
>echo "Error (${retVal}) last bisync. Doing a resync." >> "$LOGFILE"
>
>rclone bisync --resync ${OPTS}
>
>else
>
>echo "rclone bisync finished without error." >> "$LOGFILE"
>
>fi
​
https://redd.it/17rzabs
@r_bash
"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
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
},
Grep/Sed from hit until 2nd newline
Hello,
Im fairly new to linux and bash/scripting 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
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
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 scripting in Bash/Powershell ? or virtual desktop like MS want to do with Azure for mostly everything
https://redd.it/17r45fa
@r_bash
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 script 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
Veriphone API for Laravel applications.
Veriphone API is a REST based JSON API. It provides a set of stateless endpoints that any program or web browser can call by sending a standard HTTP request. Veriphone will respond with a standard HTTP response carrying a JSON payload. This documentation describes these endpoints, their input/output parameters and authentication methods.
​
https://github.com/slvler/veriphone-service
https://redd.it/17mhvhb
@r_bash
Troubles when quoting grep statement for array
Hey all!
The idea is to get an array of space-separated colors from a global config file. This works but shellcheck keeps complaining about the $1 var not being quoted. However when I single quote it the variable isn't expanded.read -ra hexCols <<< "$(grep ^$1 $mainConf | cut -d: -f2 | xargs)"
I'm sure I'm missing something obvious but as I'm quite new to this I'm struggling to see what.
I hope someone can help!
https://redd.it/17m9bjb
@r_bash
unexpected bash code behavior: won't total up numbers
I'm having trouble understanding why the bash program exits when the user enters integers.
total=0 # keeps track of the running total
# while the number of arguments isn't zero
# and the argument is an integer,
# add to the integer to the running total
# move to the next argument and check
# it against the req's (i.e. integer?)
while [ $# -gt 0 && $1 =~ ^-?[0-9+$ ]]; do
total=$((total + $1))
shift
done
# if the user entered something other than an
# integer or entered nothing at all
# display the error message "this program...."
if ! [ $1 =~ ^-?[0-9+$]]; then
echo "program only accepts integers"
echo "usage: $0 integer 1 integer 2 ... integer x"
exit
fi
# lastly, display the total
echo $total
I can't spot the error...
https://redd.it/17lsfnf
@r_bash
Script doesnt fully work
Hello guys
So because of the recent decision of youtube making people not be able to watch ad-free videos with adblocker extension, I wanted to create an script so that I can watch videos with mpv. The issue I have with mpv is that the it doesnt buffer fast enough for me. So I wanted to combine yt-dlp with mpv.
Now my script is ready but it has an issue. It works when I run each command from the script on my own with the terminal. But when running the script via bash y.bash, it doesnt perform the last command.
This is my script:
url=$(xsel -bo)
filename=$(shuf -i 1-10000000 -n 1)
fileextension="webm"
yt-dlp -o - "$url" | mpv --input-ipc-server=/tmp/mpvsocket - &
yt-dlp -o "/home/reddituser/Downloads/yt-dlp/$filename.$fileextension" "$url" && fullname="/home/reddituser/Downloads/yt-dlp/${filename}.${fileextension}"
timestamp=\"$(echo '{ "command": "get_property", "time-pos" }' | socat - /tmp/mpvsocket | jq -r '.data' | awk '{printf "%.6f\n", $1}')\"
echo $timestamp
echo '{ "command": "loadfile", "'"$fullname"'" }' | socat - /tmp/mpvsocket
echo "{ \"command\": \"set\", \"time-pos\", $timestamp }" | socat - /tmp/mpvsocket
The is the last command, that doesnt work
echo "{ \"command\": \"set\", \"time-pos\", $timestamp }" | socat - /tmp/mpvsocket
This is how the script works:
1. variable "$url" is set to the value of clipboard
2. generate random filename
3. set webm as file extension
4. download (from $url) temporarily a 720p video with yt-dlp and directly pipe it to mpv, mpv directly plays the 720p video, also uses IPC so that I can get some values, make it run in the background with "&"
5. Download a high quality version (from $url), and save it to my location with the filename being $filename.$fileextension, wait until done and then set the variable $fullname for the fullpath&fullname
6. Value of $timestamp equals the current timestamp of the 720p video playing, example \\"RANDOM_FLOATIANG_POINT\\" or \\"23.23953\\"
7. Yes It needs to be escaped with \\"
8. replace the current 720p video playing with the new high resolution downloaded video
9. Set the timestamp for the high resolution video to the one of 720p had right before it got replaced
Now the issue is command 9 doesnt work.
I get this error: {"request_id":0,"error":"error running command"}
The reason for this script is to directly watch the youtube video and replace it as soon as possible with a high resolution one that got downloaded, this way I can seek very fast without buffering and I am not anymore reliant on youtube.
​
https://redd.it/17lr9m5
@r_bash
Sed How to uncomment two lines in a file
Let's say I have a very long configuration file, and in it there's the following lines:
/etc/animals.conf
-----------------
#[cats]
#Include = /etc/cats.d/listofcats
/etc/animals.conf
-----------------
[cats]
Include = /etc/cats.d/listofcats
Deferring process substitution
So here is a very basic example of process substitution:bash --init-file <(echo "echo 4")
This will result in the number 4 being printed at the onset of a new bash session. However, in the following case, the number is not printed:docker exec -it ubuntu_container bash --init-file <(echo "echo 4")
For anyone unfamiliar, this command connects to an existing docker container named 'ubuntu_container' and executes the bash command. Although this successfully results in starting a bash session within the container, the number 4 is not printed.
My best guess is that the process substitution executes immediately, resulting in a filepath that is valid outside the container, but invalid within the container. Thus it cannot be used when starting a bash session inside the container.
Does anyone know of a way to get this second example to work? My topic title refers to 'deferring' the process substitution because if I could defer it until after entering the docker container, I believe everything would work.
Thank you.
​
(EDIT: For anyone curious, what I'm actually trying to do is to launch bash inside a docker container with a custom prompt by setting the PS1 environmental variable.)
https://redd.it/17smxs8
@r_bash
Is there a way to save executed keyboard shortcuts from the cli to a file or to stdout?
Sometimes I'd be exploring the different keybinding I have and I accidentally pressed a combination (like Alt + U or I'd change from emacs to vim or whatever) but I wouldn't know what I'd press because I'm just messing around or I pressed this keyboard shortcut by accident.
Is there a way to output to stdout or save to a file that, for example, says I pressed alt + u and give a short description that mentions I changed the text to upper case or I pressed ctrl + y and that yanks the line.
I accidentally fat finger my keyboard shortcuts all the time and I can't figure out what I just pressed. It would help me debug my keyboard shortcut and learn what I actually pressed.
https://redd.it/17sagaf
@r_bash
Syntax error due to wrong parsing
Is there a way to fix the syntax in the *SEARCH\_STRING* to avoid the error ?
Script:
*SEARCH\_STRING="search sourcetype="datasource" "denied" earliest=-60m | rex field=\_raw* ***"from (?<from>.\*)"*** *|table from |stats count by from |sort -count"*
*curl -H "Authorization: Bearer $TOKEN" -X POST https://$SPLUNK\_HOST:8089/services/search/jobs -d search="$SEARCH\_STRING";*
​
Output:
*$ ./splunk\_search.bash*
*./splunk\_search.bash: line 9: syntax error near unexpected token \`('*
*./splunk\_search.bash: line 9: \`SEARCH\_STRING="search sourcetype="datasource" "denied" earliest=-60m | rex field=\_raw "from (?<from>.\*)" |table from |stats count by from |sort -count"'*
https://redd.it/17s0yjf
@r_bash
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
"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
,
wc, piping & stdout
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
How to find the youngest file in dir1 and then find all files younger than that in dir2, recursively?
Like the title 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
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
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
Usernames from other files
Say I had a text file of usernames and in another bash script I needed to use those usernames for it to advance how would I make that so it basically Denys access if the username is not in the other file
https://redd.it/17mttty
@r_bash
line counting plugin
Hey people,
I've created a plugin that I want to share with you.
Here's the link: https://github.com/Nelliguns/line-counter-tmux
The reason for creating this plugin is that I received the question of how many lines of code it took to create a specific project of mine where I then started going through the different files and roughly summing them in my head. Which then sparked the idea of making this plugin.
Give it a try and let me now what you think, happy to receive feedback and ideas of improvements.
Hope you like it :)
https://redd.it/17mcp7b
@r_bash
TIL bash -c takes up to 2 arguments
I expected bash -c 'echo "[$@]"' 10 20 30 to print 10 20 30 but surprisingly it only showed 20 30.
On the other hand bash -c 'echo "[$0 $@]"' 10 20 30 prints 10 20 30.
In man page I found this:
-c
If the -c option is present, then commands are read from the
first non-option argument commandstring. **If there are arguments after the commandstring, the first argument is assigned
to $0 and any remaining arguments are assigned to the positional parameters. The assignment to $0 sets the name of the
shell, which is used in warning and error messages.
Did you know this?
https://redd.it/17lxfr9
@r_bash
My Useful Shell Functions
https://muhammadraza.me/2023/shell-functions/
https://redd.it/17lt0vo
@r_bash
Minimalistic Bash script to fuzzy search and open chrome bookmarks from cli
Hello bash fellows,
I was a bit annoyed by reopening my frequently used bookmarks in Chrome. I added an extension called Quickmarks but don't like it that much. I want to be faster. And I want to have fuzzy search.
Hence, I decided to create a script that fetches all my bookmarks from the file system and opens a fuzzy search session on the bookmark titles. On selection, it opens the related url in Chrome.
https://preview.redd.it/b8lshwkl5pxb1.png?width=2002&format=png&auto=webp&s=f384841958dd466c45ac468c77d7707f30f2ff66
It works pretty well. What do you think? What is your workaround for this?
Link to the script 👉 https://github.com/fynnfluegge/mydotfiles/blob/main/.scripts/fzfbookmarks.sh
https://redd.it/17l7gzt
@r_bash
Sed scripting help
I want to modify paths explicitly written in files to remove one case of ../
For example:
Somedir/../../hw
Somedir/../../../sw
now becomes after using the sed
Somedir/../hw
Somedir/../../sw
I know for certain the ../ will be in between a known directory name (Somedir in this ex) and a folder with some name (hw and sw in this ex).
Please help anyone with this.
https://redd.it/17l3qjn
@r_bash