r_bash – Telegram
How to assign default value to variable and convert to uppercase in 1 line?

I typed this in the browser search box and Google AI said this is supposed to work

VAR=${VAR^^:-DEFAULT_VALUE}

I tried it inside a noscript file (.sh) and in the console and it does not work.

Any ideas on how it can be done? thanks

PS: I'm using bash 5.x



https://redd.it/1p7uof7
@r_bash
Bash tool to view Linux group info

I was reading the book "Practical Linux System Administration" and it mentioned the "groupmems" command, and I noticed it's missing on Debian 13. So I wrote a small Bash noscript to view regular group members and improved it over a few days.
It only shows regular group info. It can list groups with no members, it separates users for whom a group is primary from those for whom it’s supplementary, and a few other small features.
I'll add some account sprawl checks to it I guess.
If you think of anything practical that fits the scope, I can add it.

https://github.com/mim-s/gshow

https://redd.it/1p6qjkd
@r_bash
I challenge you to answer this question :)

Which awk command will correctly parse the /proc/1234/smaps file to sum the Pss (Proportional Set Size) memory for all private, clean memory mappings belonging to the process?

A. awk '/^Pss:/ {pss=$2} /Private_Clean/ {sum += pss} END {print sum}' /proc/1234/smaps

B. awk '/^Pss:/ {sum += $2} END {print sum}' /proc/1234/smaps

C. awk '/Private_Clean/ {getline; if ($1=="Pss:") sum+=$2} END {print sum}' /proc/1234/smaps

D. awk 'BEGIN {RS="\\n\\n"} /Private_Clean/ {for(i=1;i<=NF;i++) if($i=="Pss:") {sum+=$(i+1); break}} END {print sum}' /proc/1234/smaps

https://redd.it/1p836c3
@r_bash
Script creating tmux session

Hi, I am finding it difficult to get the desired outcome from the following line in my server start noscript.

tmux new-session -d -s ${TMUX_SESSION} ${SERVER_COMMAND} | tee -a ${LOG}

This starts the server properly in Tmux and I'm able to connect to the session and send commands in other noscripts. My problem is specifically with tee not appending the output of the server command to the log. It seems to be appending the output of the Tmux new-session command (which is nothing).

I've tried putting the server command and tee in ` but I get command too long error.

I've also tried issuing the start command the same way I do the server action commands with tmux send-keys. My server starts and logging is correct, but the tmux session is not persistent so I can't review and I believe my action commands won't run.

Any ideas for nesting this properly?

https://redd.it/1p89exy
@r_bash
bash: warning: command substitution: ignored null byte in input

i don't even know if it's right to post it here, but I'm having that problem whenever I try to use bash-completion with yay -S ... I don't know what to do. I thought it was Starship so I deleted it, but it kept happening. It's not something that is going to k1ll me, but I would love if anyone could help me.



https://redd.it/1p9t4j3
@r_bash