r_bash – Telegram
Github to Codeberg Bulk Migration Script

github 2 codeberg

Hello there!

I just made a noscript that allows the user to "bulk migrate" repositories from github to codeberg directly, if anyone is interested, more here: https://www.rahuljuliato.com/posts/github\_to\_codeberg

https://redd.it/1cop0a7
@r_bash
is there a way for see w x h in list of pics? ls -lh ¿w x h?

Hi, is it a way for see a list with w and h of pics?

w and h is the size of pics... width x height

I use imagemagick for it and If you know how IM command identify -format [%wx%h] * | more show in list tell me how because I only get a horizontal list all pic's data in the same file and I use pipe more for page the list because bash if not showme only first to right-margin

thank you and rigards

https://redd.it/1cp35oh
@r_bash
Scripting projects and learning to deploy applications

A product support engineer who's an aspiring sysadmin(linux) wants to have elaborative knowledge on "bash shell noscripting" as well as in "deploying applications over the linux virtual machine(without using k8s, docker etc, just pure shell noscript or ansible)".

I don't want to be a software developer but want to be a systems administrator. I am working as a product support engineer and want to enhance my skillset on noscripting and deployment. They say "learn by doing", so I want to follow it. But the issue is that I am unable to find what to do. There's very minimal need of noscripting in my day to day workflow. Even if there's need of noscripting, I have to use chatgpt to write it because the issues that I require aren't from beginner to advanced level sorted out.



Similarly goes for deployment. I can use chatgpt to write deployment ansible but I won't learn anything that way. Thus, I want a guided project based way to learn these two things. I am from Nepal and such jobs are in high demand as we're using old technologies in our country. Traditional tech is well paid. I haven't seen anyone using AWS in Nepal.

https://redd.it/1cpajfz
@r_bash
What is a Subshell and Child-processs and how are they used when writing a noscript?



https://redd.it/1cpjdxl
@r_bash
Is it possible to convert bash noscripts into Python noscripts?

Just wondering If it's possible

https://redd.it/1cpljyt
@r_bash
Why is last command not running?

I have a noscript that creates a temp file with filenames, it then feeds that list to clamscan for scanning only files that have been modified. I'd like to open the log file with the application "kate" at the end of the noscript and then exit the existing terminal. It isn't working. The noscript runs the scan, but then just exits without opening the logfile. What am I doing wrong?

#!/usr/bin/bash
# CLAMSCAN RECENTLY CHANGED FILES
# DIRECTORIES TO SCAN
scandir="/home/"
# TEMPORARY FILE
list
file=$(mktemp -t clamscan.XXXXXX) || exit 1
# LOCATION OF LOG FILE
logfile="/home/clamweekly.log"
# MAKE LIST OF NEW FILES
if [ -f "$log
file" ]
then
# use newer files then logfile
find "$scandir" -type f -cnewer "$logfile" -fprint "$listfile"
else
# scan modified in last 7 days
find "$scan
dir" -type f -ctime -7 -fprint "$listfile"
fi

if [ -s "$list
file" ]
then
# Scan files
clamscan -i -f "$listfile" > "$logfile"
else
# remove the empty file, contains no info
rm -f "$listfile"
fi
# OPEN THE LOG FILE TO REVIEW AND CLOSE THE TERMINAL
kate $log
file & disown
exit

https://redd.it/1cq428r
@r_bash
Data onion help

I am making a kind of data onion of sorts for someone where the end goal is to find a text file.

I do not know a lot about bash or coding in general but the person who im making it for does. He's basically a pro. I would like to get some help with encrypting or hiding the file using bash, and just generally making it difficult/ annoying.

Any help is appreciated.

https://redd.it/1cqb7lf
@r_bash
Run command as another user exactly as if the other user opened a prompt and typed the command

Im the root and want to run a command as the notroot user, how to make the command run like this -

su - notroot
echo $PATH
whoami
echo $-


Output

/usr/local/bin:<paths from .bashrc>
notroot
himBHs


Tried

/bin/bash -c 'sudo --login -u notroot echo $-'
/bin/bash -c 'sudo --login -u notroot echo $PATH'


Output

hBc
Missing .bashrc paths


Is there a way so all the things I define in the .bashrc (mainly additions to PATH) will show when exec command as another user



https://redd.it/1cqvdo7
@r_bash
Script for Watch Folder and then Copy sub-folders

New to noscripting, so I apologize for the most-likely-obvious question.

I'm looking to create a watch folder (testsource) and copy the sub-folders and their contents to a different location (testdest), then delete the original.

#!/bin/bash
source_d="/test/testsource/"
destination_d1="/test/testdest/"
inotifywait -m -q -e close_write "$source_d" |
while read -r path action file; do
cp -- "$path$file" "$destination_d1"
# rm -- "$path$file"
done

When I create files in /test/testsource, they are detected and copied to /test/testdest. But if I copy a folder with a testfile in it (/test/testsource/testfolder/testfile1) it does not. I did notice that if I then place a file into /test/testsource (test/testsource/testfile2), it will copy both the file as well as the other subfolder.

I presume its the "$path$file" format that is wrong, but I don't know what should be used. I tried "$path" but it didn't copy anything. I tried with " cp -r $path" but also didn't get it to work.

https://redd.it/1cqyi1f
@r_bash
Get file contents into a variable - the file is referenced by a variable

I want to get the contents of a file into a variable, but the file is referenced by a variable.

The code below hangs the session, and I have to break out.

resultsfile=~/results.txt

messagebody="$(cat $resultsfile)"

It is the same if I remove the quote marks.

If I simply messagebody=$(cat ~/results.txt) it works as I expect.

I have also tried using quotes on the $resultsfile (fails with cat: '': No such file or directory, and placing $resultsfile inside escaped quotes (fails with cat: '""': No such file or directory

I feel I'm missing something basic but can't quite get the syntax correct.

https://redd.it/1crc9d3
@r_bash
Can Make be used as a replacement for bash?

Hi,
I am a complete novice at make butbhave used bash fairly regularly. Recently my manager suggested to use make instead of bash. Not just in some use cases but in general, like "lets do everything with make as it is easier to debug than bash".
Now I don't understand make not I claim to be an expert in bash, but just by googling a bit i understood that make is mainly used as a built tool and might not be as general purpose as bash. Is that it or can make actually be used as a replacement of bash? I don't find the argument "easier to debug" convincing enough but see it as a more of a skill issue e.g. same goes for make for me, I don't know make so it's not easier to debug for me.

https://redd.it/1crhvpt
@r_bash
what is a "stack" in the bash shell?

hello, i keep hearing people talk about this thing called a "stack" in the bash shell

what is that? that is a "stack"?

thank you

https://redd.it/1crkta6
@r_bash
Help me improving my tmux start up noscript

So after I boot up my WSL2 Ubuntu I have a small noscript to setup my tmux session and start VsCode. It does (mostly) what it's suppost to do and I'm working on the next iteration:

#!/bin/bash

SESSIONNAME="main"
tmux has-session -t $SESSIONNAME >? /dev/null

if $? != 0
then
tmux new-session -s $SESSIONNAME -n admin -d
tmux new-window -n project -t $SESSIONNAME:
tmux send-keys -t $SESSIONNAME 'cd ./pyprojects/' Enter 'code' Enter

fi
tmux attach -t $SESSIONNAME
cd ~/pyprojects

So far so good. The frist flaw of this program is that it will create another 'project' window if called again. I'm unsure how to prevent this.

Secondly, the next step would be to source the last utilized Python venv. I haven't though of how to keep track of this. So for now I would go with just a default venv, stored in an env variable.

At the moment I'm mainly wondering if send-keys is actually the best / proper way of interacting with my tmux session. I'm affraid I'll be limited in what I can do from this bash noscript, as "things are happening in another console". So I'd be interested in your adivice here.

Also I'm interested in your ideas on how to track what venv had been used last. I thought using the fact, that VsCode keeps track of the last project, however I havn't been able to find/use this information.

https://redd.it/1croxg6
@r_bash
need help with xargs or mv

so im trying to move all files and folders within /sdcard1/Download/ to /sdcard/daya excluding a folder name dualnine in /sdcard1/Download. Here is the command i used

find /sdcard1/Download/ -mindepth 1 -maxdepth 1 ! -name dualnine | xargs mv -f /sdcard/daya/

but i get an error saying mv: dir at '/sdcard/daya/'

Can anyone pls explain I don't understand what is wrong

https://redd.it/1crq4fw
@r_bash
Bash and Unix course help

Hello!

I have been working for the past year or so as a DevOps engineer, the position relies on many tools and technologies and basic-intermediate Unix and python. I have been encountering more and more difficulties lately at work due to my limited knowledge of Unix, I know and understand the basics but I'm having some difficulties with Intermediate level stuff. So far, I have been heavily relying on ChatGPT to save me in these scenarios but this deducts from my learning.

I want a course on the Intermediate level that will help me with generic Unix and bash noscripting, stuff like getting a directory and splitting it based on "/" then printing one element, stuff like escaping characters and when they are used (bonus points if Dockerfiles are mentioned in specific), how quotation marks work and why " is different than ' or """ . I have already read on these things but I was wondering if a specific course would cover these better than lazily reading a bit of documentation and putting 0 practice in it.

https://redd.it/1csgfsx
@r_bash
.bashrc that overrides every command?

I wanted to know if it is possible to create like some troll .bashrc that every command/shell builtin commands/path to executable file it encounters it will override it and do some other action.

https://redd.it/1csi3s8
@r_bash
Amber - the programming language compiled to Bash

Hi! I'm Paweł, and I'm excited to introduce **Amber**, a new programming language that compiles to Bash. Amber offers three key advantages over traditional shell noscripting:

* **A modern and familiar syntax**, similar to Ruby or Rust, that's easy to learn and use.
* **Type safety**, which ensures robust error handling and prevents common mistakes.
* **Runtime safety**, which means the compiler forces you to handle all potential errors during compilation, making your code more reliable.

Want to learn more? Check out [https://amber-lang.com](https://amber-lang.com) for additional information.

https://preview.redd.it/2exig1gm3n0d1.png?width=1854&format=png&auto=webp&s=658c49e477dc2705444d001d752a95d35ace275d

https://redd.it/1cst3zy
@r_bash
using sed to insert '[foo]' string in a file

I am looking for a way to insert multiple lines of text into a file. I am exploring sed. I understand that the \[\] are meta characters that introduce a character class but is there a way to escape them so that I can insert them as plain text; something like this into a text file:

[header]
answer=1
foo=true
bar=never

This is the sed command I am using. I am trying to exca

# sed -i '76 i\\
\[fips_sect\] \\
activate = 1 \\
conditional-errors = 1\\
security-checks = 1 \\
' /usr/local/ssl/openssl.cnf

That attempt fails with an error:

sed: -e expression #1, char 32: unterminated address regex

What's my best approach here?


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