Check if the input file and dictionary file are provided
if [ $# -eq 0 ]; then
echo "input file and dictionary missing"
exit 1
fi
# Check if the input file is valid
input_file=$1
if [ ! -f "$input_file" ]; then
echo "$input_file is not a file"
exit 1
fi
# Check if the dictionary file is valid
dictionary_file=$2
if [ ! -f "$dictionary_file" ]; then
echo "$dictionary_file is not a file"
exit 1
fi
# Read the dictionary into an array
mapfile -t dictionary < "$dictionary_file"
# Convert dictionary array to lowercase for case-insensitive comparison
dictionary=("${dictionary[@],,}")
# Check the input file for 4-letter words
grep -o '\b[a-zA-Z]\{4\}\b' "$input_file" | while read word; do
# Convert the word to lowercase
word=$(echo "$word" | tr '[:upper:]' '[:lower:]')
# Check if the word is NOT in the dictionary
if ! [[ " ${dictionary[@]} " =~ " ${word} " ]]; then
echo "$word"
fi
done
https://redd.it/1gxdzdz
@r_bash
if [ $# -eq 0 ]; then
echo "input file and dictionary missing"
exit 1
fi
# Check if the input file is valid
input_file=$1
if [ ! -f "$input_file" ]; then
echo "$input_file is not a file"
exit 1
fi
# Check if the dictionary file is valid
dictionary_file=$2
if [ ! -f "$dictionary_file" ]; then
echo "$dictionary_file is not a file"
exit 1
fi
# Read the dictionary into an array
mapfile -t dictionary < "$dictionary_file"
# Convert dictionary array to lowercase for case-insensitive comparison
dictionary=("${dictionary[@],,}")
# Check the input file for 4-letter words
grep -o '\b[a-zA-Z]\{4\}\b' "$input_file" | while read word; do
# Convert the word to lowercase
word=$(echo "$word" | tr '[:upper:]' '[:lower:]')
# Check if the word is NOT in the dictionary
if ! [[ " ${dictionary[@]} " =~ " ${word} " ]]; then
echo "$word"
fi
done
https://redd.it/1gxdzdz
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Cannot understand why less than is not working.
Greetings.
Background information, I'm attempting to write a noscript to semi-automate tarballing a bunch of archived logs into single file for clients to download. Logrotate uses 2 digit months and days for the filenames, meaning using 07 for the month of July instead of just 7. I'm attempting to do a test to see if the month entered is under 10, so I can then prepend the numeral 0 in front of the input so tar function works. I keep getting a "input_start_month: integer expression expected" error on the highlighted line
The kicker is that the less-than-or-equal-to test above this line works fine.
read -p "Enter starting month of logs to pull in numerical format: " inputstartmonth
read -p "Enter ending month of logs to pull in numerical format: (if only within a single month, just enter the month again): " inputendmonth
# Verify Month range is valid and fix single digit input to multiple digits, i.e 5 to 05
if input_start_month -le input_end_month ; then #THIS LINE WORKS
echo "Month range is valid."
if "$input_start_month" -lt 10 ; then #ERRORS HERE
$startmonth = "0$inputstartmonth"
else
$startmonth = "$inputstartmonth"
fi
if $input_end_month -le 9 ; then
$endmonth = "0$inputendmonth"
else
$endmonth = "$inputendmonth"
fi
else
echo "ERROR! Month range is invalid."
exit 1;
fi
https://redd.it/1h16ey0
@r_bash
Greetings.
Background information, I'm attempting to write a noscript to semi-automate tarballing a bunch of archived logs into single file for clients to download. Logrotate uses 2 digit months and days for the filenames, meaning using 07 for the month of July instead of just 7. I'm attempting to do a test to see if the month entered is under 10, so I can then prepend the numeral 0 in front of the input so tar function works. I keep getting a "input_start_month: integer expression expected" error on the highlighted line
The kicker is that the less-than-or-equal-to test above this line works fine.
read -p "Enter starting month of logs to pull in numerical format: " inputstartmonth
read -p "Enter ending month of logs to pull in numerical format: (if only within a single month, just enter the month again): " inputendmonth
# Verify Month range is valid and fix single digit input to multiple digits, i.e 5 to 05
if input_start_month -le input_end_month ; then #THIS LINE WORKS
echo "Month range is valid."
if "$input_start_month" -lt 10 ; then #ERRORS HERE
$startmonth = "0$inputstartmonth"
else
$startmonth = "$inputstartmonth"
fi
if $input_end_month -le 9 ; then
$endmonth = "0$inputendmonth"
else
$endmonth = "$inputendmonth"
fi
else
echo "ERROR! Month range is invalid."
exit 1;
fi
https://redd.it/1h16ey0
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Linux Foundation Certificate Shell Scripting using Bash (SC103)
I got a coupon to attempt the certificate exam SC103 from The Linux Foundation. Wondering if anyone has given this exam? How should I prepare specifically for this exam as this would be online proctored exam. I have few months before the voucher expires. Any suggestions would be appreciated.
https://redd.it/1h1qfjy
@r_bash
I got a coupon to attempt the certificate exam SC103 from The Linux Foundation. Wondering if anyone has given this exam? How should I prepare specifically for this exam as this would be online proctored exam. I have few months before the voucher expires. Any suggestions would be appreciated.
https://redd.it/1h1qfjy
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Parsing byte counts
A few noscripts I wrote have "byte count" as an optional input. Id like these to accept using prefixes (e.g., 64 kb or 128 MiB). But, there are 2 competing systems at play here.
kilobyte is 1000, megabyte is 1000^2, etc.
kibibyte is 1024, mebibyte is 1024^2, etc.
Is there some universally agreed upon syntax for which prefic abbreviations map to 1000^n vs which map to 1024^N?
NOTE: for my use cases it doesnt make sense to specify bit count, so wshether or not there is a trailing
My intuition here is that
1000^N:
k, kb, kB --> 1000
m, mb, mB --> 1000^2
etc.
1024^N:
K, Ki, ki, Kb, Kib, kib, KB, KiB, kiB --> 1024
M, Mi, mi, Mb, Mib, mib, MB, MiB, miB --> 1024^2
etc.
Are there any commonly used programs that would conflict with this mapping?
As far as the actual implementation, I use something like
getBytes() {
local +i nn
local -A byteMap
byteMap=([k]=1 [m]=2 [g]=3 [t]=4 [p]=5 [e]=6)
for nn in "${@}"; do
nn="${nn//[bB ]/}"
case "${nn}" in
kmgtpe)
echo "$(( ${nn//^0-9/} ( 1000 ${byteMap[${nn//[0-9]/}]} ) ))"
;;
KMGTPEIi)
nn="${nn,,}"
nn="${nn%i}"
echo "$(( ${nn//^0-9/} ( 1024 ${byteMap[${nn//[0-9]/}]} ) ))"
;;
)
echo "${nn//^0-9/}"
;;
esac
done
}
but if anyone has a better implementation please do suggest it!
https://redd.it/1h230p8
@r_bash
A few noscripts I wrote have "byte count" as an optional input. Id like these to accept using prefixes (e.g., 64 kb or 128 MiB). But, there are 2 competing systems at play here.
kilobyte is 1000, megabyte is 1000^2, etc.
kibibyte is 1024, mebibyte is 1024^2, etc.
Is there some universally agreed upon syntax for which prefic abbreviations map to 1000^n vs which map to 1024^N?
NOTE: for my use cases it doesnt make sense to specify bit count, so wshether or not there is a trailing
b or B it will always refer to bytes.My intuition here is that
1000^N:
k, kb, kB --> 1000
m, mb, mB --> 1000^2
etc.
1024^N:
K, Ki, ki, Kb, Kib, kib, KB, KiB, kiB --> 1024
M, Mi, mi, Mb, Mib, mib, MB, MiB, miB --> 1024^2
etc.
Are there any commonly used programs that would conflict with this mapping?
As far as the actual implementation, I use something like
getBytes() {
local +i nn
local -A byteMap
byteMap=([k]=1 [m]=2 [g]=3 [t]=4 [p]=5 [e]=6)
for nn in "${@}"; do
nn="${nn//[bB ]/}"
case "${nn}" in
kmgtpe)
echo "$(( ${nn//^0-9/} ( 1000 ${byteMap[${nn//[0-9]/}]} ) ))"
;;
KMGTPEIi)
nn="${nn,,}"
nn="${nn%i}"
echo "$(( ${nn//^0-9/} ( 1024 ${byteMap[${nn//[0-9]/}]} ) ))"
;;
)
echo "${nn//^0-9/}"
;;
esac
done
}
but if anyone has a better implementation please do suggest it!
https://redd.it/1h230p8
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Understanding heredoc variable substitution
Hello, I'm confused about the output of this noscript:
Foo="bar"
cat << EOF
a $Foo
$Foo
EOF
This outputs:
a bar
Foo
It looks like variables at the start of a line don't get substituted. Can I work around that?
https://redd.it/1h2kcfd
@r_bash
Hello, I'm confused about the output of this noscript:
Foo="bar"
cat << EOF
a $Foo
$Foo
EOF
This outputs:
a bar
Foo
It looks like variables at the start of a line don't get substituted. Can I work around that?
https://redd.it/1h2kcfd
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Can someone ELI5 "trailing newline", what the -n command means, the -e command and what "echo" is?
I am trying to have an understanding of what these things actually mean and have an understanding of it.
The more I read the more confused I get, if someone could explain it so a child could understand it I would appreciate it.
https://redd.it/1h2vykk
@r_bash
I am trying to have an understanding of what these things actually mean and have an understanding of it.
The more I read the more confused I get, if someone could explain it so a child could understand it I would appreciate it.
https://redd.it/1h2vykk
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Can you change the escape key in vi mode?
I want to use ctrl+c like I use in my editor to enter normal mode
https://redd.it/1h33g39
@r_bash
I want to use ctrl+c like I use in my editor to enter normal mode
https://redd.it/1h33g39
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Escape $ to write literal placeholders
Hi,
Newbie here, apologies in advance if my question is not appropriate.
I have a bash noscript that installs some software, and I would like to generate a networkd-dispatcher noscript.
The networkd-dispatcher noscript should contain placeholders such as "$IFACE" and "$UNIT_NAME", but the installation noscript interprets them as undeclared variables, and the networkd-dispatcher noscripts ends up with empty spaces.
How can I escape these "$"?
This is what I have at the moment in the installation noscript:
createnetworkdnoscript() {
cat << EOF > $HOME/BirdNET-Pi/templates/50-birdweather-publication
#!/bin/bash
UNITNAME="birdweatherpublication@$IFACE.service"
# Check if the service is active and then start it
if systemctl is-active --quiet "$UNITNAME"; then
echo "$UNITNAME is already running."
else
echo "Starting $UNITNAME..."
systemctl start "$UNITNAME"
fi
EOF
chmod +x $HOME/BirdNET-Pi/templates/50-birdweather-publication
chown root:root $HOME/BirdNET-Pi/templates/50-birdweather-publication
ln -sf $HOME/BirdNET-Pi/templates/50-birdweather-publication /etc/networkd-dispatcher/routable.d
systemctl enable systemd-networkd
}
createnetworkdnoscript
https://redd.it/1h47zez
@r_bash
Hi,
Newbie here, apologies in advance if my question is not appropriate.
I have a bash noscript that installs some software, and I would like to generate a networkd-dispatcher noscript.
The networkd-dispatcher noscript should contain placeholders such as "$IFACE" and "$UNIT_NAME", but the installation noscript interprets them as undeclared variables, and the networkd-dispatcher noscripts ends up with empty spaces.
How can I escape these "$"?
This is what I have at the moment in the installation noscript:
createnetworkdnoscript() {
cat << EOF > $HOME/BirdNET-Pi/templates/50-birdweather-publication
#!/bin/bash
UNITNAME="birdweatherpublication@$IFACE.service"
# Check if the service is active and then start it
if systemctl is-active --quiet "$UNITNAME"; then
echo "$UNITNAME is already running."
else
echo "Starting $UNITNAME..."
systemctl start "$UNITNAME"
fi
EOF
chmod +x $HOME/BirdNET-Pi/templates/50-birdweather-publication
chown root:root $HOME/BirdNET-Pi/templates/50-birdweather-publication
ln -sf $HOME/BirdNET-Pi/templates/50-birdweather-publication /etc/networkd-dispatcher/routable.d
systemctl enable systemd-networkd
}
createnetworkdnoscript
https://redd.it/1h47zez
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Advent of Code 2024 - Day 1 Problem 1 Solution in Bash
Hi, I have been learning Bash the last two days as my first noscripting language. I saw the advent of code started this year, and I thought why not try to solve it with Bash (since it's the only language I know so far." I managed to solve most of it by myself, had only to look for the sort command.
---
# Bash solution for day 1 problem 1
## Summary of the problem
- 2 Teams are searching for the locations where the Chief Historian might be.
- Each location has a 'location ID'.
- 2 Groups trying to make a complete list of 'location ID'.
- The two lists are not similar.
- Pair the smallest 'location ID' from the left with the smallest 'location ID' from the right
- Measure the distance (difference) between each 'location ID' pair.
- Measure the total aggregate distance between all 'location ID' pairs.
# inputs
A text file with the 2 lists is presented in the following format
## Steps to solution
1. Separate the numbers in the text file into two lists.
2. Order the numbers in each list from the smallest to the biggest.
3. Measure the distance between each 2 respective numbers.
4. Measure the total of distances.
## Solution
Save the numbers in a text file called input.txt"
https://redd.it/1h4t92n
@r_bash
Hi, I have been learning Bash the last two days as my first noscripting language. I saw the advent of code started this year, and I thought why not try to solve it with Bash (since it's the only language I know so far." I managed to solve most of it by myself, had only to look for the sort command.
---
# Bash solution for day 1 problem 1
## Summary of the problem
- 2 Teams are searching for the locations where the Chief Historian might be.
- Each location has a 'location ID'.
- 2 Groups trying to make a complete list of 'location ID'.
- The two lists are not similar.
- Pair the smallest 'location ID' from the left with the smallest 'location ID' from the right
- Measure the distance (difference) between each 'location ID' pair.
- Measure the total aggregate distance between all 'location ID' pairs.
# inputs
A text file with the 2 lists is presented in the following format
18944 47230
94847 63037
93893 35622
## Steps to solution
1. Separate the numbers in the text file into two lists.
2. Order the numbers in each list from the smallest to the biggest.
3. Measure the distance between each 2 respective numbers.
4. Measure the total of distances.
## Solution
Save the numbers in a text file called input.txt"
#!/bin/bash
# Generate an array from the input
list=(`cat input.txt`)
# Save the even elements into list.left.txt and the odd elements into list.right.txt
for el in "${!list[@]}"
do
rem=$((${el} % 2))
if [[ rem -eq 0 ]]
then
echo "${list[$el]}" >> list.left.txt
else
echo "${list[$el]}" >> list.right.txt
fi
done
# Sorting the numbers
sort list.left.txt > list.left.sorted.txt
sort list.right.txt > list.right.sorted.txt
# create arrays from the two files
left=(`cat list.left.sorted.txt`)
right=(`cat list.right.sorted.txt`)
# calculate the difference and save it to a text file.
for ele in "${!left[@]}"
do
diff=$(("${left[$ele]}"-"${right[$ele]}"))
if [ $diff -ge 0 ]
then
echo "$diff" >> diffs.txt
else
diff=$(($diff * -1))
echo "$diff" >> diffs.txt
fi
done
# Import the differences as an array
di=(`cat diffs.txt`)
total=0
for elem in ${di[@]}
do
total=$(($total + $elem))
done
echo "$total"
https://redd.it/1h4t92n
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Why this loop doesn't break the first time?
Here, the condition
https://redd.it/1h526bx
@r_bash
while read -r line
do
echo "$line"
done <file.txt
Here, the condition
read -r line has nothing to read the first time the loop runs, why it doesn't break the first time?https://redd.it/1h526bx
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Move files from all subfolders to root folder but new filename should contain the folders
Hello,
i have a lot of folders containing files and more sobfolders with files. I want to have all that files in the root folder and the filename should contain the folder name. For example the file /testdir1/testdir2/testfile,txt should be in /testdir1_-_testdir2_-_testfile.txt
The thing is, some years ago i had done this by accident (i think i tried just to remove bad characters from filename but by accident also replaces the / but i can't get it together again :-( )
https://redd.it/1h5mrsi
@r_bash
Hello,
i have a lot of folders containing files and more sobfolders with files. I want to have all that files in the root folder and the filename should contain the folder name. For example the file /testdir1/testdir2/testfile,txt should be in /testdir1_-_testdir2_-_testfile.txt
The thing is, some years ago i had done this by accident (i think i tried just to remove bad characters from filename but by accident also replaces the / but i can't get it together again :-( )
https://redd.it/1h5mrsi
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Any way to hook into 'command not found' and run a noscript / function?
Curious if there's any way to hook into the error condition 'command not found' and run a noscript/function? Basically, I'd like to do something similar to "thefuck" but have it run automatically.
$ doesnotexist
-bash: doesnotexist: command not found
# how to (automatically) call some custom function/noscript/etc?
# preferably with access to bash history so I can run a
# fuzzy find with target command vs my defined aliases
So far my searches keep coming up with irrelevant stuff so I'm not sure if I'm just using bad search terms or if this is something that is just not possible under bash.
https://redd.it/1h65lkg
@r_bash
Curious if there's any way to hook into the error condition 'command not found' and run a noscript/function? Basically, I'd like to do something similar to "thefuck" but have it run automatically.
$ doesnotexist
-bash: doesnotexist: command not found
# how to (automatically) call some custom function/noscript/etc?
# preferably with access to bash history so I can run a
# fuzzy find with target command vs my defined aliases
So far my searches keep coming up with irrelevant stuff so I'm not sure if I'm just using bad search terms or if this is something that is just not possible under bash.
https://redd.it/1h65lkg
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
I made a bash noscript to exclude dropbox sync directories via command line
I code a lot in my dropbox folder to keep them synced across my devices (before git commits are viable) and unfortunately dropbox does not include an automatic way to exclude syncs. Took a while but with some guidance from claude 3.5 I hacked this together.
https://github.com/kavehtehrani/dropbox-exclude
https://redd.it/1h716kg
@r_bash
I code a lot in my dropbox folder to keep them synced across my devices (before git commits are viable) and unfortunately dropbox does not include an automatic way to exclude syncs. Took a while but with some guidance from claude 3.5 I hacked this together.
https://github.com/kavehtehrani/dropbox-exclude
https://redd.it/1h716kg
@r_bash
GitHub
GitHub - kavehtehrani/dropbox-exclude: A bash noscript to easily exclude directories from Dropbox sync using pattern matching
A bash noscript to easily exclude directories from Dropbox sync using pattern matching - kavehtehrani/dropbox-exclude
How to exclude a directory from find and rsync except for a few very specific files?
I'm struggling with nested include/exclude for find and rsync.
I want to find or rsync my dotfiles, except for the .mozilla folder (among some others). But I want the login data of firefox preserved. So far, I have
find -path '*/.*' -not -path '*/.cache/*' -not -path '*/.mozilla/*' -path '*/.mozilla/firefox/*.default-release/{autofill-profiles,signedInUser,prefs}.js*' > dotfiles
which gives back a blank file. How can I do this properly to exclude the majority of stuff from one directory, but still include these specific files?
I haven't yet tackled this for rsync (and maybe tar), but solutions for these are also welcome.
https://redd.it/1h75w8x
@r_bash
I'm struggling with nested include/exclude for find and rsync.
I want to find or rsync my dotfiles, except for the .mozilla folder (among some others). But I want the login data of firefox preserved. So far, I have
find -path '*/.*' -not -path '*/.cache/*' -not -path '*/.mozilla/*' -path '*/.mozilla/firefox/*.default-release/{autofill-profiles,signedInUser,prefs}.js*' > dotfiles
which gives back a blank file. How can I do this properly to exclude the majority of stuff from one directory, but still include these specific files?
I haven't yet tackled this for rsync (and maybe tar), but solutions for these are also welcome.
https://redd.it/1h75w8x
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Debug bash prompt
I have this in my .bashrc file for the terminal prompt and it works fine but when cursor moves beyond half of the terminal width then it messes with the text on screen. The cursor does not go beyond that point instead moves to the start of the line.
# Colours
foregroundcolor='\033[0;1;36m'
commandforeground='\0330m'
background_color_black='\033[30m'
background_color_cyan='\033[46m'
# Prompt components
info="${foreground_color}${background_color_black}${background_color_cyan}\A${foreground_color} ${foreground_color}${background_color_black}${background_color_cyan}\d${foreground_color}"
align_right='\033[$(($COLUMNS-20))C'
start='\033[1G'
prompt="${foreground_color}--> ${command_foreground}"
# Prompt string
PS1="${align_right}${info}${start}${prompt}"
https://i.redd.it/w5gzsfrzhu4e1.gif
[https://redd.it/1h6hvuw
@r_bash
I have this in my .bashrc file for the terminal prompt and it works fine but when cursor moves beyond half of the terminal width then it messes with the text on screen. The cursor does not go beyond that point instead moves to the start of the line.
# Colours
foregroundcolor='\033[0;1;36m'
commandforeground='\0330m'
background_color_black='\033[30m'
background_color_cyan='\033[46m'
# Prompt components
info="${foreground_color}${background_color_black}${background_color_cyan}\A${foreground_color} ${foreground_color}${background_color_black}${background_color_cyan}\d${foreground_color}"
align_right='\033[$(($COLUMNS-20))C'
start='\033[1G'
prompt="${foreground_color}--> ${command_foreground}"
# Prompt string
PS1="${align_right}${info}${start}${prompt}"
https://i.redd.it/w5gzsfrzhu4e1.gif
[https://redd.it/1h6hvuw
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
I Asked ChatGPT About ‘ShowFilesHere’—It Took Me to the Actual Project Link!
https://github.com/andrewrgarcia/files-here-wzrd
https://redd.it/1h7um27
@r_bash
https://github.com/andrewrgarcia/files-here-wzrd
https://redd.it/1h7um27
@r_bash
GitHub
GitHub - andrewrgarcia/files-here-wzrd: Capture, share, and rebuild your project’s file structure with ease. Perfect for sharing…
Capture, share, and rebuild your project’s file structure with ease. Perfect for sharing and AI-driven project generation. - andrewrgarcia/files-here-wzrd
Need help passing argument with alias
Hi,
I want to make an alias with the word cheat. Ex. cheat topic
I tried making an alias but can't get it right. I presume because there is whitespace between the command and the argument.
alias cheat="curl cht.sh/$1"
How can I make this alias work so when I type cheat zip, and make curl cht.sh.zip the result?
Thanks.
https://redd.it/1h7p3vn
@r_bash
Hi,
I want to make an alias with the word cheat. Ex. cheat topic
I tried making an alias but can't get it right. I presume because there is whitespace between the command and the argument.
alias cheat="curl cht.sh/$1"
How can I make this alias work so when I type cheat zip, and make curl cht.sh.zip the result?
Thanks.
https://redd.it/1h7p3vn
@r_bash
replacing placeholders in a file with variables from a noscript
Yeah, this noscript probably doesn't make sense so here I go...
I have a txt file with a bunch of html code that will make up a person's signature. In the txt file I have {{firstname}} {{lastname}} and {{email}}. In my bash noscript I have variables $firstname $lastname and $email. I want to write the txt file to a html file but replace the placeholders in the txt file with what the variables are.
https://redd.it/1h7li6n
@r_bash
Yeah, this noscript probably doesn't make sense so here I go...
I have a txt file with a bunch of html code that will make up a person's signature. In the txt file I have {{firstname}} {{lastname}} and {{email}}. In my bash noscript I have variables $firstname $lastname and $email. I want to write the txt file to a html file but replace the placeholders in the txt file with what the variables are.
https://redd.it/1h7li6n
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Error Handling in Bash: 5 Essential Methods with Examples
https://jsdev.space/error-handling-bash/
https://redd.it/1h7xvee
@r_bash
https://jsdev.space/error-handling-bash/
https://redd.it/1h7xvee
@r_bash
JavaScript Development Space
Error Handling in Bash: 5 Essential Methods with Examples
Learn effective Bash error handling with exit status, set -e, traps, logging, and custom functions to make your noscripts more reliable and robust.
Unexpected evaluatoin of "date +%M" in ~/.bashrc
I use the following command in an alias in my bashrc
Why on earth does it evaluate to something like
https://redd.it/1h81d98
@r_bash
I use the following command in an alias in my bashrc
$(date +%Y)/$(date +%M)/KW$(date +%V)-$(( $(date +%V) +2))Why on earth does it evaluate to something like
2024/23/KW49-51 and an ever changing month? I cannot even figure out, what is the problem. Sometimes when sourcing the bashrc I get a new month, sometimes not. What is happening here?https://redd.it/1h81d98
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Exports block prev exports
I'm using zshell and my config exports are like that. But when i want to use lazygit or openvpn etc. it says '...not included path.' I add it with export or via config file but then I can't even use ls. Say's I have to add it to path It's in the path on .zshrc. Couldn't find solution pls help. Everything works fine in root terminal but it's not suitable i guess.
https://preview.redd.it/8qtx9l58495e1.png?width=817&format=png&auto=webp&s=3a0a8e4e448a86ccb451d407ffa769b21adbff99
https://preview.redd.it/cxqmojw0495e1.png?width=1346&format=png&auto=webp&s=5142078c29552f2707520a69cc505162c51d1983
https://redd.it/1h8576v
@r_bash
I'm using zshell and my config exports are like that. But when i want to use lazygit or openvpn etc. it says '...not included path.' I add it with export or via config file but then I can't even use ls. Say's I have to add it to path It's in the path on .zshrc. Couldn't find solution pls help. Everything works fine in root terminal but it's not suitable i guess.
https://preview.redd.it/8qtx9l58495e1.png?width=817&format=png&auto=webp&s=3a0a8e4e448a86ccb451d407ffa769b21adbff99
https://preview.redd.it/cxqmojw0495e1.png?width=1346&format=png&auto=webp&s=5142078c29552f2707520a69cc505162c51d1983
https://redd.it/1h8576v
@r_bash