Bug in find command
Hi everyone,
I’m having an issue with my find command that I can’t seem to figure out.
Command:
find . -type d -iname “NamePattern*” -exec cp -rf {} /tmp \;
Sometimes the above command works properly by copying the resulting folder into /tmp (desired outcome)
Other times it copies all the files inside the resulting folder into /tmp. This is not expected.
I’m not sure why the behaviour keeps changing. It displays both behaviours even if the search pattern is the same. I run the command for the same folder and yet one time it copies the folder and the next time it copies all the files from inside the folder.
Can someone please help me understand what I am doing wrong here and how to fix this?
https://redd.it/16iy1o8
@r_bash
Hi everyone,
I’m having an issue with my find command that I can’t seem to figure out.
Command:
find . -type d -iname “NamePattern*” -exec cp -rf {} /tmp \;
Sometimes the above command works properly by copying the resulting folder into /tmp (desired outcome)
Other times it copies all the files inside the resulting folder into /tmp. This is not expected.
I’m not sure why the behaviour keeps changing. It displays both behaviours even if the search pattern is the same. I run the command for the same folder and yet one time it copies the folder and the next time it copies all the files from inside the folder.
Can someone please help me understand what I am doing wrong here and how to fix this?
https://redd.it/16iy1o8
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Found Useful Code to use, but don't Grasp Parts of It (newbie!)
I was looking to make a GUI pop-up to input the sudo password for a noscript I'm making. I'm a complete novice to bash noscripting and I came across another Reddit post that had some code that was able to do what I needed, but I'm not sure what some of it does:
fatal() {
echo "FATAL ERROR: $@"
exit 1
}
trap 'sudo -k' EXIT
zenity --password | sudo -Sv || fatal "Unable to sudo"
It's going at the beginning of my noscript, and I can understand what its supposed to be doing, but there's just a few parts I'm trying to understand about it, if that makes any sense...
In the fatal function, I'm not sure what the "$@" part of the echo command is or how it works, I tried googling it, but I couldn't really understand what I was reading or it gave examples of some other noscripts that I couldn't fully decipher.
I tried looking but apparently I don't have a manual on the trap command, and after some googling, I have a vague understanding of it.
Last part, I'm having a hard time grasping the explanations of the -Sv options of the sudo man page.
I was hoping someone might be able to explain one or all of those in as simplified a manner as possible so my tiny brain can grasp their concepts
https://redd.it/16j2ze4
@r_bash
I was looking to make a GUI pop-up to input the sudo password for a noscript I'm making. I'm a complete novice to bash noscripting and I came across another Reddit post that had some code that was able to do what I needed, but I'm not sure what some of it does:
fatal() {
echo "FATAL ERROR: $@"
exit 1
}
trap 'sudo -k' EXIT
zenity --password | sudo -Sv || fatal "Unable to sudo"
It's going at the beginning of my noscript, and I can understand what its supposed to be doing, but there's just a few parts I'm trying to understand about it, if that makes any sense...
In the fatal function, I'm not sure what the "$@" part of the echo command is or how it works, I tried googling it, but I couldn't really understand what I was reading or it gave examples of some other noscripts that I couldn't fully decipher.
I tried looking but apparently I don't have a manual on the trap command, and after some googling, I have a vague understanding of it.
Last part, I'm having a hard time grasping the explanations of the -Sv options of the sudo man page.
I was hoping someone might be able to explain one or all of those in as simplified a manner as possible so my tiny brain can grasp their concepts
https://redd.it/16j2ze4
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
How do I correctly copy and paste into the terminal?
If I wanted to paste this into the terminal as is
file=randomfile
while IFS= read -r line
do
echo $line
done < "$file"
It comes out looking weird and it doesn't run. There are new lines and it's not pasted correctly.
<~>$ file=randomfile
S= read -r line<~>$ while IFS= read -r line> do
echo $line
> done < "$file"
How do you usually copy and paste simple snippets of bash code found on stackoverflow onto the terminal without saving into a file through vim?
And sometimes if it does paste into the terminal without it looking all weird, it executes automatically, is there a reason for that?
https://redd.it/16j4ecc
@r_bash
If I wanted to paste this into the terminal as is
file=randomfile
while IFS= read -r line
do
echo $line
done < "$file"
It comes out looking weird and it doesn't run. There are new lines and it's not pasted correctly.
<~>$ file=randomfile
S= read -r line<~>$ while IFS= read -r line> do
echo $line
> done < "$file"
How do you usually copy and paste simple snippets of bash code found on stackoverflow onto the terminal without saving into a file through vim?
And sometimes if it does paste into the terminal without it looking all weird, it executes automatically, is there a reason for that?
https://redd.it/16j4ecc
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Discovery survival
_Discovery Survival_
Wanna be apart of something great ? Introducing Discovery Survival ! With multiple PlayStation servers and Xbox as well ! Anything from pvp or just looting around we have it all !
* shop
* prio support
* custom bases
* custom killfeed
* in game credits that can be spent
* Build literally anywhere you WANT !
* Boosted loot
* Resets every 2 hours
* Many factions to join or create
* Servers NEVER wipe
* All servers weekend raids only
Come be apart of something awesome and bless us with being apart of it 😊
https://discord.gg/discoverysurvival
https://redd.it/16jdey9
@r_bash
_Discovery Survival_
Wanna be apart of something great ? Introducing Discovery Survival ! With multiple PlayStation servers and Xbox as well ! Anything from pvp or just looting around we have it all !
* shop
* prio support
* custom bases
* custom killfeed
* in game credits that can be spent
* Build literally anywhere you WANT !
* Boosted loot
* Resets every 2 hours
* Many factions to join or create
* Servers NEVER wipe
* All servers weekend raids only
Come be apart of something awesome and bless us with being apart of it 😊
https://discord.gg/discoverysurvival
https://redd.it/16jdey9
@r_bash
Discord
Join the Discovery Survival Discord Server!
The fastest growing DayZ community server for the last 2 years offering the most unique experience. | 9659 members
what does bash being a "command language" mean?
i'm reading wikipedia
https://en.wikipedia.org/wiki/Bash\_(Unix\_shell))
and it says "Bash is a Unix shell and command language"
what does that mean? what does bash being a "command language" mean? what is a command language?
https://redd.it/16jl9s1
@r_bash
i'm reading wikipedia
https://en.wikipedia.org/wiki/Bash\_(Unix\_shell))
and it says "Bash is a Unix shell and command language"
what does that mean? what does bash being a "command language" mean? what is a command language?
https://redd.it/16jl9s1
@r_bash
Oneliner to read entire Shrek noscript
https://redd.it/16jw8wz
@r_bash
sudo apt-get install -y gnustep-gui-runtime && say "$(curl http://www.noscript-o-rama.com/movie_noscripts/s/shrek-noscript-trannoscript-mike-myers.html | mawk '/<pre>/{flag=1; next} /<\/pre>/{flag=0} flag')"https://redd.it/16jw8wz
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
How to setup commitlint, auto format all bash files and auto shellcheck all bash files for a BASH only project in VSCode?
​
https://preview.redd.it/ka0g8jqhljob1.png?width=628&format=png&auto=webp&s=1d45e3aaea29a71404c3237f2a1e0e273a386f0c
I have a project on VSCode with nothing but a bunch of bash noscripts
I would like to be able to verify the commit messages to match conventional commit format everytime I want to commit something to git
I would also like to auto format all files on commit and auto shellcheck all files on commit or should I say that commit should fail if shellcheck has problems
How do I set something like this up on VSCode?
https://redd.it/16jxw0l
@r_bash
​
https://preview.redd.it/ka0g8jqhljob1.png?width=628&format=png&auto=webp&s=1d45e3aaea29a71404c3237f2a1e0e273a386f0c
I have a project on VSCode with nothing but a bunch of bash noscripts
I would like to be able to verify the commit messages to match conventional commit format everytime I want to commit something to git
I would also like to auto format all files on commit and auto shellcheck all files on commit or should I say that commit should fail if shellcheck has problems
How do I set something like this up on VSCode?
https://redd.it/16jxw0l
@r_bash
rparse: an easy-to-use shell noscript/function option parser that uses regex to determine which inputs are options
Lines in the option definition table use 1 of 2 possible syntaxes, depending on if that option has an argument associated with it.
Options without arguments use the format:
<REGEX> -> <CMDS>
For every input option that matches the <REGEX> definition, the command(s) listed in <CMDS> will run.
Options with arguments use the format:
<REGEX> => <VAR>
For every input option that matches the <REGEX> definition, the variable <VAR> will be set as the argument given along with the option.
Example
Aa? -> ((applecount++))
b(anannas?)? => banannaVar
This will:
make any of `-a` `-A` `--apple` `--Apple` `--apples` `--Apples` increment the variable `applecount` by 1
make any of
Ok, here is the code, along with a functioning simple example of using
rparse() {
## Extended-Regex sed-based options parser for bash shell functions and noscripts
#
# Define options in table. Lines of the table can have one of 2 formats:
# <REGEX> -> <CMD> ( for options without arguments. <CMD> will be run when option is read. )
# <REGEX> => <VAR> ( for options with arguments. Variable <VAR> will be set to the argument. )
#
# NOTE: Do not include the leading dash ('-') in table. Options can have any number (1+) of leading dashes.
#
# Pass the option definition table on stdin. Pass the cmdline you want to parse as function input.
#
local -a sedfilt0 ii
local -i nkk kk
nkk=0
ii=("${@}")
# transform options table into a sed filter for cmdline to parse
{
mapfile -t sedfilt0 < <(cat <&${fd0} | grep -E '.+' | sed -E 's/^(.) -> (.)$/s\/^-+\1( ^-.)? $\/\2\/; /; s/^(.) => (.) $/s\/^-+\1[= ]\/\2=\/;/')
} {fd0}<&0
# break up options into 1 per line and then run it through the sed filter we just made
# for options with arguments, keep the argument on the same line as its corresponding option
{
for kk in ${!ii[@]}; do
case "${ii[$kk]}" in
'--')
break;
;;
'-'=)
printf '\n%s ' "${ii[$kk]%%=} ${ii$kk#=}"
nkk=2
;;
-)
printf '\n%s ' "${ii$kk}"
nkk=1
;;
)
{ (( $nkk == 0 )) || (( $nkk >= 2 )); } && break
printf '%s ' "${ii[$kk]}"
((nkk++))
;;
esac
done
printf '\n'
} | sed -E "${sedfilt0[]}"
}
# define testing function
gg() {
local sedfilt flagA valB
flagA=false
# define options table
# if option '-a' or '--apple' is given, the command
# if '-b <...>' or '--bananna <...>' or '--bananna=<...>' is given, set variable "valB" to <...> (i.e., run
rparse makes it very easy to define options (inputs that start with a dash (-)) using extended regex matching. Using regex makes it possible to define many options in a single short string, and allow for a degree of "fuzzy" option matching, should you desire it. These regex option definitions and what is triggered by said options is added into an "option definition table" and passed to rparse (via stdin) along with the commandline you want parsed (via function input). rparse will take this info and return a list of commands to run based on the options that were present.Lines in the option definition table use 1 of 2 possible syntaxes, depending on if that option has an argument associated with it.
Options without arguments use the format:
<REGEX> -> <CMDS>
For every input option that matches the <REGEX> definition, the command(s) listed in <CMDS> will run.
Options with arguments use the format:
<REGEX> => <VAR>
For every input option that matches the <REGEX> definition, the variable <VAR> will be set as the argument given along with the option.
Example
Aa? -> ((applecount++))
b(anannas?)? => banannaVar
This will:
make any of `-a` `-A` `--apple` `--Apple` `--apples` `--Apples` increment the variable `applecount` by 1
make any of
-b <...> --bananna <...> --banannas <...> -b=<...> --bananna=<...> --banannas=<...> result in settting banannaVar=<...>Ok, here is the code, along with a functioning simple example of using
rparse. Let me know what you think!rparse() {
## Extended-Regex sed-based options parser for bash shell functions and noscripts
#
# Define options in table. Lines of the table can have one of 2 formats:
# <REGEX> -> <CMD> ( for options without arguments. <CMD> will be run when option is read. )
# <REGEX> => <VAR> ( for options with arguments. Variable <VAR> will be set to the argument. )
#
# NOTE: Do not include the leading dash ('-') in table. Options can have any number (1+) of leading dashes.
#
# Pass the option definition table on stdin. Pass the cmdline you want to parse as function input.
#
rparse will output the commands that you want to run. source the output to actually run them.local -a sedfilt0 ii
local -i nkk kk
nkk=0
ii=("${@}")
# transform options table into a sed filter for cmdline to parse
{
mapfile -t sedfilt0 < <(cat <&${fd0} | grep -E '.+' | sed -E 's/^(.) -> (.)$/s\/^-+\1( ^-.)? $\/\2\/; /; s/^(.) => (.) $/s\/^-+\1[= ]\/\2=\/;/')
} {fd0}<&0
# break up options into 1 per line and then run it through the sed filter we just made
# for options with arguments, keep the argument on the same line as its corresponding option
{
for kk in ${!ii[@]}; do
case "${ii[$kk]}" in
'--')
break;
;;
'-'=)
printf '\n%s ' "${ii[$kk]%%=} ${ii$kk#=}"
nkk=2
;;
-)
printf '\n%s ' "${ii$kk}"
nkk=1
;;
)
{ (( $nkk == 0 )) || (( $nkk >= 2 )); } && break
printf '%s ' "${ii[$kk]}"
((nkk++))
;;
esac
done
printf '\n'
} | sed -E "${sedfilt0[]}"
}
# define testing function
gg() {
local sedfilt flagA valB
flagA=false
# define options table
# if option '-a' or '--apple' is given, the command
flagA=true is run# if '-b <...>' or '--bananna <...>' or '--bananna=<...>' is given, set variable "valB" to <...> (i.e., run
valB=<...>)sedfilt="$(cat<<'EOF'
a(pple)? -> flagA=true
b(anannas?)? => valB
EOF
)"
# pass rparse the option table on its stdin and the commandline as function inputs, then source its output
source <({ rparse "$@"; }<<<"${sedfilt}")
# check things were set correctly
echo "flagA = ${flagA}"
echo "valB = ${valB}"
# do stuff probably
}
# try it out
gg
gg -a
gg -apple
gg -b 0
gg --bananna=1
gg -a --bananna=2
gg -b 3 --apple --bananna 4
gg -a --bananna 4 -b 3 --apple -bananna=2 -a -b=1 func arg nonoption
https://redd.it/16lpgps
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Use curl to download from password protected host
I'm writing a bash noscript which takes in a url as argument and prompts username and password inputs in order to download the file from the url. The problem is curl wants to know the target file name (which is at the end of the url) in order to download. I imagine a solution involving regex to match the end of the url to a pattern. Is there a better way to implement this ?
https://redd.it/16m4nsk
@r_bash
I'm writing a bash noscript which takes in a url as argument and prompts username and password inputs in order to download the file from the url. The problem is curl wants to know the target file name (which is at the end of the url) in order to download. I imagine a solution involving regex to match the end of the url to a pattern. Is there a better way to implement this ?
https://redd.it/16m4nsk
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Changing audio output with noscripts
Hello,
I want to make a noscript that changes my audio outputs if I run it
​
The problem is that my setup is a bit weird
I have 2 cards
​
alsa_card.usb-Corsair_CORSAIR_VIRTUOSO_Wireless_Gaming_Headset_16adc305000000da-00
​
​
alsa_card.pci-0000_01_00.1
​
​
And with this there would be no problems, but I have problems with the fact that under the pci card I have two profiles, output:hdmi-stereo-extra1 and output:hdmi-stereo-extra2 one is my TV the other is my monitorAnd also I would need to disable all other cards/profiles so new and existing audio is forced on the newly set output
​
I tried searching google for solutions but most either causes my audio to not even work, or because of the profile settings does not want to go from Headphones into TV and things like this
​
Any help would be nice
EDIT: I would need to do this in 3 separate noscripts, since I have 3 outputs I want to use
https://redd.it/16mw7sl
@r_bash
Hello,
I want to make a noscript that changes my audio outputs if I run it
​
The problem is that my setup is a bit weird
I have 2 cards
​
alsa_card.usb-Corsair_CORSAIR_VIRTUOSO_Wireless_Gaming_Headset_16adc305000000da-00
​
​
alsa_card.pci-0000_01_00.1
​
​
And with this there would be no problems, but I have problems with the fact that under the pci card I have two profiles, output:hdmi-stereo-extra1 and output:hdmi-stereo-extra2 one is my TV the other is my monitorAnd also I would need to disable all other cards/profiles so new and existing audio is forced on the newly set output
​
I tried searching google for solutions but most either causes my audio to not even work, or because of the profile settings does not want to go from Headphones into TV and things like this
​
Any help would be nice
EDIT: I would need to do this in 3 separate noscripts, since I have 3 outputs I want to use
https://redd.it/16mw7sl
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
getopts "require" flag (or running noscript with no flags just shows usage)
Hey all,
I've got a generic noscript that I'd like to *require* a/any flag in order for it do anything, and if no flag is included (i.e. just running ./foo.sh) outputs the usage function.
​
So:
running
running
running
​
Note: none of the flags require any arguments. The flags alone is all that's needed
​
Full getopts part of function will be in a comment so as to not fill the OP
https://redd.it/16n07lb
@r_bash
Hey all,
I've got a generic noscript that I'd like to *require* a/any flag in order for it do anything, and if no flag is included (i.e. just running ./foo.sh) outputs the usage function.
​
So:
running
./foo.sh outputs via 'echo' ./foo.sh [ -s \] to do bar, ./foo.sh [ -d \] to do foobarrunning
./foo.sh -s does foorunning
./foo.sh -d does foobar​
Note: none of the flags require any arguments. The flags alone is all that's needed
​
Full getopts part of function will be in a comment so as to not fill the OP
https://redd.it/16n07lb
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Format Bash Command – apply indentation and line breaks
https://ray.run/tools/bash-command-formatter
https://redd.it/16n234s
@r_bash
https://ray.run/tools/bash-command-formatter
https://redd.it/16n234s
@r_bash
ray.run
Format Bash Command
A Bash command formatter tool takes in a Bash command and formats it, applying proper indentation, line breaks, and formatting to make it more readable and structured.
Question about read command
I need my read loop to break when it hits an empty line. I was suggested to use this command, but I am confused why the "-z $line" conditional is true when there is an empty line?
while IFS= read -r line; do
if [ -z $line ]; then
break
​
https://redd.it/16nbzro
@r_bash
I need my read loop to break when it hits an empty line. I was suggested to use this command, but I am confused why the "-z $line" conditional is true when there is an empty line?
while IFS= read -r line; do
if [ -z $line ]; then
break
​
https://redd.it/16nbzro
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Here is VEDV written in pure BASH, A tool for developing applications with virtual machines using a Docker-like workflow.
The software we are developing needs to be tested on a system as closed as possible to the one where it is going to be executed. Sometimes it is very difficult to satisfy this requirement with docker and we have to use virtual machines missing the docker workflow. This is why I started the development of vedv. I hope you find it useful. Thank you.
https://github.com/yunielrc/vedv
​
https://redd.it/16mvdnf
@r_bash
The software we are developing needs to be tested on a system as closed as possible to the one where it is going to be executed. Sometimes it is very difficult to satisfy this requirement with docker and we have to use virtual machines missing the docker workflow. This is why I started the development of vedv. I hope you find it useful. Thank you.
https://github.com/yunielrc/vedv
​
https://redd.it/16mvdnf
@r_bash
GitHub
GitHub - yunielrc/vedv: A tool for developing in a secure and reproducible environment
A tool for developing in a secure and reproducible environment - GitHub - yunielrc/vedv: A tool for developing in a secure and reproducible environment
Working with fzf - The Command-Line Fuzzy Finder
https://muhammadraza.me/2023/fzf/
https://redd.it/16nkjz7
@r_bash
https://muhammadraza.me/2023/fzf/
https://redd.it/16nkjz7
@r_bash
Muhammad Raza
fzf - The Command-Line Fuzzy Finder | Muhammad
Dive into fzf: the ultimate command-line fuzzy finder. Master terminal searches, enhance productivity, and streamline tasks with this must-have tool.
Can get env when run the noscript via SSH
// Look at the picture first in case TLDR
I have a noscript like this:
deploy_test_env.sh
#!/bin/bash
echo $ENVVAR
$ENV\VAR is an env variable on the host I want to run deploy_test_env.sh.
When I try to run this noscript normally, it works fine.
But when I run it by pipe it into ssh like this:
\-ssh $SSH_USERNAME@$SSH_HOSTNAME 'bash -s' < ./deploy_test_env.sh
The output is nothing.
I have edited the \~/.bashrc on the remote host also.
​
https://preview.redd.it/sthy0zxxlfpb1.png?width=1152&format=png&auto=webp&s=f2284c7ed235f205a097e65a3ef94177d3550094
https://redd.it/16nonv2
@r_bash
// Look at the picture first in case TLDR
I have a noscript like this:
deploy_test_env.sh
#!/bin/bash
echo $ENVVAR
$ENV\VAR is an env variable on the host I want to run deploy_test_env.sh.
When I try to run this noscript normally, it works fine.
But when I run it by pipe it into ssh like this:
\-ssh $SSH_USERNAME@$SSH_HOSTNAME 'bash -s' < ./deploy_test_env.sh
The output is nothing.
I have edited the \~/.bashrc on the remote host also.
​
https://preview.redd.it/sthy0zxxlfpb1.png?width=1152&format=png&auto=webp&s=f2284c7ed235f205a097e65a3ef94177d3550094
https://redd.it/16nonv2
@r_bash
Give value tp variable through ssh from windows
There are any solution to give values to variable through ssh? i echo the variable to check its blank
ssh user@remoteip "
backuppath=/some/path
read -p 'Do you really want to delete backups [Y/n\] ' Answer;
if [ $answer ==Y \]; then
find $backuppath -type d -name ""BKP_*"" -exec rm -rf {} \\;
echo "backups deleted"
else
echo ""ERRO""
"
There are any solotion to give values to variable through ssh?
Thanks in advance.
https://redd.it/16nr13u
@r_bash
There are any solution to give values to variable through ssh? i echo the variable to check its blank
ssh user@remoteip "
backuppath=/some/path
read -p 'Do you really want to delete backups [Y/n\] ' Answer;
if [ $answer ==Y \]; then
find $backuppath -type d -name ""BKP_*"" -exec rm -rf {} \\;
echo "backups deleted"
else
echo ""ERRO""
"
There are any solotion to give values to variable through ssh?
Thanks in advance.
https://redd.it/16nr13u
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
bash noscript help
Hello everyone,
I am trying to do this bash noscript that allows me to choose between .conf files in /etc/wireguard and at the end of it will execute wg-quick ... it is giving me configuration not found, the files exist...can someone tell me where I am failing please..much appreciated. Thank you.
#!/bin/bash
# Directory where WireGuard configuration files are stored
CONFIG_DIR="/etc/wireguard"
# List all files in the configuration directory
config_files=("gb-mnc-wg-007.conf" "pt-lis-wg-102.conf")
# Prompt user to choose a configuration file
echo "Available WireGuard configuration files:"
for ((i=0; i<${#config_files[@]}; i++)); do
echo "[$i] $(basename "${config_files[i]}")"
done
read -p "Enter the number of the configuration file you want to execute: " choice
# Validate user input
if [[ ! "$choice" =~ ^[0-9]+$ ]] || ((choice < 0)) || ((choice >= ${#config_files[@]})); then
echo "Invalid choice. Please enter a valid number."
exit 1
fi
# Get the chosen configuration file
selected_config="${config_files[choice]}"
# Execute WireGuard with the chosen configuration
if [[ -f "$selected_config" ]]; then
sudo wg-quick up "$CONFIG_DIR/$selected_config"
echo "WireGuard configuration '$selected_config' has been activated."
else
echo "Configuration file not found."
exit 1
fi
​
https://redd.it/16nyb0n
@r_bash
Hello everyone,
I am trying to do this bash noscript that allows me to choose between .conf files in /etc/wireguard and at the end of it will execute wg-quick ... it is giving me configuration not found, the files exist...can someone tell me where I am failing please..much appreciated. Thank you.
#!/bin/bash
# Directory where WireGuard configuration files are stored
CONFIG_DIR="/etc/wireguard"
# List all files in the configuration directory
config_files=("gb-mnc-wg-007.conf" "pt-lis-wg-102.conf")
# Prompt user to choose a configuration file
echo "Available WireGuard configuration files:"
for ((i=0; i<${#config_files[@]}; i++)); do
echo "[$i] $(basename "${config_files[i]}")"
done
read -p "Enter the number of the configuration file you want to execute: " choice
# Validate user input
if [[ ! "$choice" =~ ^[0-9]+$ ]] || ((choice < 0)) || ((choice >= ${#config_files[@]})); then
echo "Invalid choice. Please enter a valid number."
exit 1
fi
# Get the chosen configuration file
selected_config="${config_files[choice]}"
# Execute WireGuard with the chosen configuration
if [[ -f "$selected_config" ]]; then
sudo wg-quick up "$CONFIG_DIR/$selected_config"
echo "WireGuard configuration '$selected_config' has been activated."
else
echo "Configuration file not found."
exit 1
fi
​
https://redd.it/16nyb0n
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
How did you made this incredible banners.... in your noscripts
Hello guys I was thinking how the hell is possible to make incredible banners like this and what would you recommend me to be a pro in noscripting(bash) ? I like to learn by books and videos.
https://preview.redd.it/69qmvubiajpb1.png?width=1030&format=png&auto=webp&s=5884d84e5461069031fb4be748771358c1ad22bf
https://preview.redd.it/0iuk8hhdajpb1.png?width=544&format=png&auto=webp&s=4b2c04debab9cdb9428d6281287db8ed7aa2b5a0
https://redd.it/16o61qm
@r_bash
Hello guys I was thinking how the hell is possible to make incredible banners like this and what would you recommend me to be a pro in noscripting(bash) ? I like to learn by books and videos.
https://preview.redd.it/69qmvubiajpb1.png?width=1030&format=png&auto=webp&s=5884d84e5461069031fb4be748771358c1ad22bf
https://preview.redd.it/0iuk8hhdajpb1.png?width=544&format=png&auto=webp&s=4b2c04debab9cdb9428d6281287db8ed7aa2b5a0
https://redd.it/16o61qm
@r_bash
Here is ydf written in full BASH, The disruptive dotfiles manager+
https://github.com/yunielrc/ydf
https://redd.it/16o5sla
@r_bash
https://github.com/yunielrc/ydf
https://redd.it/16o5sla
@r_bash
GitHub
GitHub - yunielrc/ydf: A dotfiles manager+. Be ready to work in just a few minutes on your Fresh OS
A dotfiles manager+. Be ready to work in just a few minutes on your Fresh OS - yunielrc/ydf