This media is not supported in your browser
VIEW IN TELEGRAM
I was searching for the most SIMPLE way to take quick notes on my terminal with the current stack... no editor is needed + to be able to group them by topics, so I end up with this small bash function note!
https://redd.it/11vhlju
@r_bash
https://redd.it/11vhlju
@r_bash
How to execute all functions by mask?
Hi,I've got a number of functions in my
How can I execute them all at once by mask
https://redd.it/11vkbao
@r_bash
Hi,I've got a number of functions in my
.bashrc. () {blabla2} () {blabla4} () {blabla_n} How can I execute them all at once by mask
rdp-?
rdp-doesn't work.
https://redd.it/11vkbao
@r_bash
Reddit
r/bash on Reddit: How to execute all functions by mask?
Posted by u/turbuhale - No votes and 2 comments
How to delete everything before third slash?
https://tube.cadence.moe/channel/UCVls1GmFKf6WlTraIbIaJg
https://tube.cadence.moe/watch?v=KsiPYMKSHU8
https://youtube.com/channel/UCVls1GmFKf6WlTraIbIaJg
https://youtube.com/watch?v=KsiPYMKSHU8
https://vid.puffyan.us/channel/UCVls1GmFKf6WlTraIbIaJg
https://vid.puffyan.us/watch?v=KsiPYMKSHU8
How to delete everything before third slash? Results should look like this
/channel/UCVls1GmFKf6WlTraIbIaJg
/watch?v=KsiPYMKSHU8
/channel/UCVls1GmFKf6WlTraIbIaJg
/watch?v=KsiPYMKSHU8
/channel/UCVls1GmFKf6WlTraIbIaJg
/watch?v=KsiPYMKSHU8
How can this be done?
https://redd.it/11vy9vg
@r_bash
https://tube.cadence.moe/channel/UCVls1GmFKf6WlTraIbIaJg
https://tube.cadence.moe/watch?v=KsiPYMKSHU8
https://youtube.com/channel/UCVls1GmFKf6WlTraIbIaJg
https://youtube.com/watch?v=KsiPYMKSHU8
https://vid.puffyan.us/channel/UCVls1GmFKf6WlTraIbIaJg
https://vid.puffyan.us/watch?v=KsiPYMKSHU8
How to delete everything before third slash? Results should look like this
/channel/UCVls1GmFKf6WlTraIbIaJg
/watch?v=KsiPYMKSHU8
/channel/UCVls1GmFKf6WlTraIbIaJg
/watch?v=KsiPYMKSHU8
/channel/UCVls1GmFKf6WlTraIbIaJg
/watch?v=KsiPYMKSHU8
How can this be done?
https://redd.it/11vy9vg
@r_bash
Print value of key in associative array
I feel like this is pretty simple but I can't make it work. I have an associative array that has keys and values. When I loop through it using:
for key in "${!array@}"
do
... code here ...
if [ condition ];
echo "The value of $key is $???"
I've tried all I can think of. I thought I could do
​
Also of note: I can use
https://redd.it/11vxzo8
@r_bash
I feel like this is pretty simple but I can't make it work. I have an associative array that has keys and values. When I loop through it using:
for key in "${!array@}"
do
... code here ...
if [ condition ];
echo "The value of $key is $???"
I've tried all I can think of. I thought I could do
${array[$key]} but that doesn't work. I'm not sure what I'm missing here.​
Also of note: I can use
${array[$key]} when making comparisons between what's at the key and other variables. It's just blank when I try and print it.https://redd.it/11vxzo8
@r_bash
Reddit
r/bash on Reddit: Print value of key in associative array
Posted by u/Mailstorm - No votes and 1 comment
Why does this byte mess with what the characters look like?
When I use 'cat' on a certain binary file on my Raspberry Pi, it changed what each character looks like. Almost like it's changing a byte in RAM that shifts what each letter look is mapped to. For example, 'a' is changed to the UTF-8 symbol '▓'.
And I feel like it's "changing a byte in RAM" because it has no effect when being used in WSL.
The byte in question is '0e'. I get the same problem when using 'echo -ne "\\\\x0e"'. This is what it looks like when used on my Pi:
https://preview.redd.it/tisf0lpevsoa1.jpg?width=4032&format=pjpg&auto=webp&v=enabled&s=bb823b6d98cbf539c7b2542116b4af238a713742
And it being used in WSL:
https://preview.redd.it/05ppw6yhvsoa1.png?width=548&format=png&auto=webp&v=enabled&s=3a7d2ff9784f2be02499d1a954627b805423b89b
​
Why would this one byte have this effect on my Pi and not my emulator?
Edit:
One thing to add is that the look of each character changed, but nothing else. So typing 'a' on the keyboard shows "▓" on the terminal, but is still understood as 'a'.
https://redd.it/11w4zn4
@r_bash
When I use 'cat' on a certain binary file on my Raspberry Pi, it changed what each character looks like. Almost like it's changing a byte in RAM that shifts what each letter look is mapped to. For example, 'a' is changed to the UTF-8 symbol '▓'.
And I feel like it's "changing a byte in RAM" because it has no effect when being used in WSL.
The byte in question is '0e'. I get the same problem when using 'echo -ne "\\\\x0e"'. This is what it looks like when used on my Pi:
https://preview.redd.it/tisf0lpevsoa1.jpg?width=4032&format=pjpg&auto=webp&v=enabled&s=bb823b6d98cbf539c7b2542116b4af238a713742
And it being used in WSL:
https://preview.redd.it/05ppw6yhvsoa1.png?width=548&format=png&auto=webp&v=enabled&s=3a7d2ff9784f2be02499d1a954627b805423b89b
​
Why would this one byte have this effect on my Pi and not my emulator?
Edit:
One thing to add is that the look of each character changed, but nothing else. So typing 'a' on the keyboard shows "▓" on the terminal, but is still understood as 'a'.
https://redd.it/11w4zn4
@r_bash
The output of launching a noscript with grep commands does not include any color, whereas the output of launching the grep commands is indeed colorful. How can I get the colors back while running the noscript? Thanks
https://redd.it/11wca0j
@r_bash
https://redd.it/11wca0j
@r_bash
Reddit
r/bash on Reddit: The output of launching a noscript with grep commands does not include any color, whereas the output of launching…
Posted by u/goahead97 - No votes and no comments
I added flags to a simple noscript to please people
I modified several of the noscripts in my [BASH\_Scripts\_For\_Everyone](https://github.com/wolandark/BASH_Scripts_For_Everyone) repo to include a -h help flag and other appropriate ones to the noscripts function.Here is a noscript called `betterfeh` for setting the wallpaper with feh and automatically changing it based on a given interval or the default 120 seconds.This noscript can also apply the wallpapers in the array in reverse order with the -r flag and can start from a random wallpaper in the array.Let me know what you think.
#!/bin/bash
# Written By Woland
# Sets wallpapers and changes them automatically
#Dependency:
# feh
# change PIC_DIR to point to your wallpapers directory & run the noscript
# if -t is provided, it must precede other flags
# https://github.com/wolandark
# https://github.com/wolandark/BASH_Scripts_For_Everyone
#Default interval for changing the wallpapers
default_interval=120
#Wallpapers path
PIC_DIR="/home/woland/Pictures/HD/Landscape/"
PIC_LIST=("$PIC_DIR"*)
#Help msg
usage () {
echo "Usage: $0 [-h] [-t interval] [-e] [-r reverse]"
echo "Options:"
echo " -t interval Set wallpaper change interval in seconds (default: $default_interval). Must precede other flags if provided"
echo " -e Start from a random wallpaper"
echo " -r Set wallpaper in reverse order"
echo " -h Display this help message"
}
#Main Function
set_pic() {
local interval=${1:-$default_interval}
while true
do
if [ "$2" == "-r" ]; then
for (( i=${#PIC_LIST[@]}-1; i>=0; i-- ))
do
feh --bg-scale "${PIC_LIST[i]}"
sleep "${interval}"
done
elif [ "$2" == "-e" ]; then
random_pic=${PIC_LIST[$RANDOM % ${#PIC_LIST[@]}]}
for i in "${sorted_array[@]}"
do
feh --bg-scale "$i"
sleep "${interval}"
done
else
# Loop through the array normally if no flag is given
for i in "${PIC_LIST[@]}"
do
feh --bg-scale "$i"
sleep "${interval}"
done
fi
done
}
#getops
while getopts ":ht:re" opt; do
case ${opt} in
h ) usage
exit 0
;;
t )
interval=${OPTARG}
;;
r )
set_pic ${interval:-$default_interval} "-r"
exit 0
;;
e )
set_pic ${interval:-$default_interval} "-r"
exit 0
;;
\? )
echo "Invalid argument: -$OPTARG" 1>&2
exit 1
;;
: )
interval=${default_interval}
;;
esac
done
shift $((OPTIND -1))
interval=${interval:-$default_interval}
# Call the set_pic function
if [ -z "${1}" ]; then
set_pic ${interval}
else
set_pic ${1} ${interval}
fi
https://redd.it/11wgvqv
@r_bash
I modified several of the noscripts in my [BASH\_Scripts\_For\_Everyone](https://github.com/wolandark/BASH_Scripts_For_Everyone) repo to include a -h help flag and other appropriate ones to the noscripts function.Here is a noscript called `betterfeh` for setting the wallpaper with feh and automatically changing it based on a given interval or the default 120 seconds.This noscript can also apply the wallpapers in the array in reverse order with the -r flag and can start from a random wallpaper in the array.Let me know what you think.
#!/bin/bash
# Written By Woland
# Sets wallpapers and changes them automatically
#Dependency:
# feh
# change PIC_DIR to point to your wallpapers directory & run the noscript
# if -t is provided, it must precede other flags
# https://github.com/wolandark
# https://github.com/wolandark/BASH_Scripts_For_Everyone
#Default interval for changing the wallpapers
default_interval=120
#Wallpapers path
PIC_DIR="/home/woland/Pictures/HD/Landscape/"
PIC_LIST=("$PIC_DIR"*)
#Help msg
usage () {
echo "Usage: $0 [-h] [-t interval] [-e] [-r reverse]"
echo "Options:"
echo " -t interval Set wallpaper change interval in seconds (default: $default_interval). Must precede other flags if provided"
echo " -e Start from a random wallpaper"
echo " -r Set wallpaper in reverse order"
echo " -h Display this help message"
}
#Main Function
set_pic() {
local interval=${1:-$default_interval}
while true
do
if [ "$2" == "-r" ]; then
for (( i=${#PIC_LIST[@]}-1; i>=0; i-- ))
do
feh --bg-scale "${PIC_LIST[i]}"
sleep "${interval}"
done
elif [ "$2" == "-e" ]; then
random_pic=${PIC_LIST[$RANDOM % ${#PIC_LIST[@]}]}
for i in "${sorted_array[@]}"
do
feh --bg-scale "$i"
sleep "${interval}"
done
else
# Loop through the array normally if no flag is given
for i in "${PIC_LIST[@]}"
do
feh --bg-scale "$i"
sleep "${interval}"
done
fi
done
}
#getops
while getopts ":ht:re" opt; do
case ${opt} in
h ) usage
exit 0
;;
t )
interval=${OPTARG}
;;
r )
set_pic ${interval:-$default_interval} "-r"
exit 0
;;
e )
set_pic ${interval:-$default_interval} "-r"
exit 0
;;
\? )
echo "Invalid argument: -$OPTARG" 1>&2
exit 1
;;
: )
interval=${default_interval}
;;
esac
done
shift $((OPTIND -1))
interval=${interval:-$default_interval}
# Call the set_pic function
if [ -z "${1}" ]; then
set_pic ${interval}
else
set_pic ${1} ${interval}
fi
https://redd.it/11wgvqv
@r_bash
GitHub
GitHub - wolandark/BASH_Scripts_For_Everyone: A collection of BASH noscripts that might benefit all *nix users
A collection of BASH noscripts that might benefit all *nix users - wolandark/BASH_Scripts_For_Everyone
Issues with quotes usage in bash noscript
I'm trying to run this noscript but it doesnt work. I suspect it's because of the single quotes present in the first variable but I don't understand how to correct it. Any idea ?
$CurlCommand itself run but I still need to add the "/api/states/sensor.XYZ" suffix to get the exact url I need.
https://redd.it/11wjeor
@r_bash
I'm trying to run this noscript but it doesnt work. I suspect it's because of the single quotes present in the first variable but I don't understand how to correct it. Any idea ?
-----------#!/bin/shCurlCommand="curl -s -H 'Authorization: Bearer TOKENHERE' -X GET `http://123.123.123.123`"Device1="${CurlCommand}/api/states/sensor.XYZ"$Device1-----------$CurlCommand itself run but I still need to add the "/api/states/sensor.XYZ" suffix to get the exact url I need.
https://redd.it/11wjeor
@r_bash
Reddit
r/bash on Reddit: Issues with quotes usage in bash noscript
Posted by u/mrdindon - No votes and 1 comment
Last week's "Absurdly minified coloring function," now 126 bytes shorter with a github page and an absurdly maximized explanation
I spent a couple more mornings on that ANSI coloring function for bash noscripts, absurdly minified submission from last week.
Here's a new at-a-glance demo picture.
It's now got a Github page:
https://github.com/rustyflavor/clr.sh
And an explanation of how it works, which is as absurdly long as the noscript is absurdly short:
https://github.com/rustyflavor/clr.sh/wiki/How-does-this-work%3F
After incorporating most of your feedback, and chewing on it myself for another couple hours, it's down from 457 bytes to 331.
That's more than 25% shorter, and roughly 800% harder to read!
Here's the noscript as it stands now with comments removed:
((BASHVERSINFO[0]>3))&&clr(){ local i=$1 l=krgybmcw@ b g c s x
while c=${i::1};[ "$c" ]&&((g<11));do i=${i:1};b=30;case $c in +)s+=";1";;
=)s+=";22";;)s+=";4";;-)s+=";24";;.)((g+=10));;${l^^})b=90;;&${l^^}|$l)
x=${l%"${c,}"};x=${#x};x=$((x<8?x+b+g:39+g));s+=";$x";((g+=10));esac;done;
printf %b "\e[${s#;}m";}||clr(){ :;}
And, expanded again by bash's `type` builtin:
$ type clr
clr is a function
clr ()
{
local i=$1 l=krgybmcw@ b g c s x;
while c=${i::1};
[ "$c" ] && ((g<11)); do
i=${i:1};
b=30;
case $c in
+)
s+=";1"
;;
=)
s+=";22"
;;
_)
s+=";4"
;;
-)
s+=";24"
;;
.)
((g+=10))
;;
[${l^^}])
b=90
;;&
[${l^^}] | [$l])
x=${l%"${c,}"};
x=${#x};
x=$((x<8?x+b+g:39+g));
s+=";$x";
((g+=10))
;;
esac;
done;
printf %b "\e${s#;}m"
}
What do those inscrutably short variable names mean? [It's all in the wiki page.
All feedback is welcome, especially ways to shrink it even worse!
https://redd.it/11wrmdg
@r_bash
I spent a couple more mornings on that ANSI coloring function for bash noscripts, absurdly minified submission from last week.
Here's a new at-a-glance demo picture.
It's now got a Github page:
https://github.com/rustyflavor/clr.sh
And an explanation of how it works, which is as absurdly long as the noscript is absurdly short:
https://github.com/rustyflavor/clr.sh/wiki/How-does-this-work%3F
After incorporating most of your feedback, and chewing on it myself for another couple hours, it's down from 457 bytes to 331.
That's more than 25% shorter, and roughly 800% harder to read!
Here's the noscript as it stands now with comments removed:
((BASHVERSINFO[0]>3))&&clr(){ local i=$1 l=krgybmcw@ b g c s x
while c=${i::1};[ "$c" ]&&((g<11));do i=${i:1};b=30;case $c in +)s+=";1";;
=)s+=";22";;)s+=";4";;-)s+=";24";;.)((g+=10));;${l^^})b=90;;&${l^^}|$l)
x=${l%"${c,}"};x=${#x};x=$((x<8?x+b+g:39+g));s+=";$x";((g+=10));esac;done;
printf %b "\e[${s#;}m";}||clr(){ :;}
And, expanded again by bash's `type` builtin:
$ type clr
clr is a function
clr ()
{
local i=$1 l=krgybmcw@ b g c s x;
while c=${i::1};
[ "$c" ] && ((g<11)); do
i=${i:1};
b=30;
case $c in
+)
s+=";1"
;;
=)
s+=";22"
;;
_)
s+=";4"
;;
-)
s+=";24"
;;
.)
((g+=10))
;;
[${l^^}])
b=90
;;&
[${l^^}] | [$l])
x=${l%"${c,}"};
x=${#x};
x=$((x<8?x+b+g:39+g));
s+=";$x";
((g+=10))
;;
esac;
done;
printf %b "\e${s#;}m"
}
What do those inscrutably short variable names mean? [It's all in the wiki page.
All feedback is welcome, especially ways to shrink it even worse!
https://redd.it/11wrmdg
@r_bash
Reddit
r/bash on Reddit: ANSI coloring function for bash noscripts, absurdly minified
Posted by u/rustyflavor - 11 votes and 3 comments
Help with a bash noscript which uses variables and sed
Good afternoon. I am attempting to use sed -r to find a string and replace with a string that includes a defined variable. The noscript currently looks like:
#!/bin/bash
myrepo=/media/RAID5/graylog-open/opensearch/$(date +%F-%T.%z)
sed -i -r "s/([path.repo]+:\s\[.*\])/(path\.repo\:\ \[\$myrepo\])/g" /graylog/opensearch/config/opensearch.yml &&
However, as can be imagined, escaping "$" in the "\\[\\$my_repo\\\]" causes sed to replace with "$my_repo" vs. $my_repo as the variable is defined.
Failure to escape "$" causes sed to throw an "unknown option to 's'" error.
It would be ideal if sed only used regex to find the string and then replace, verbatim, with "path.repo: [<my_repo variable>\]" however, it looks like "-r" runs regex through the entirity of the command.
Does that make sense?
Any ideas?
Thank you!
https://redd.it/11wx9x9
@r_bash
Good afternoon. I am attempting to use sed -r to find a string and replace with a string that includes a defined variable. The noscript currently looks like:
#!/bin/bash
myrepo=/media/RAID5/graylog-open/opensearch/$(date +%F-%T.%z)
sed -i -r "s/([path.repo]+:\s\[.*\])/(path\.repo\:\ \[\$myrepo\])/g" /graylog/opensearch/config/opensearch.yml &&
However, as can be imagined, escaping "$" in the "\\[\\$my_repo\\\]" causes sed to replace with "$my_repo" vs. $my_repo as the variable is defined.
Failure to escape "$" causes sed to throw an "unknown option to 's'" error.
It would be ideal if sed only used regex to find the string and then replace, verbatim, with "path.repo: [<my_repo variable>\]" however, it looks like "-r" runs regex through the entirity of the command.
Does that make sense?
Any ideas?
Thank you!
https://redd.it/11wx9x9
@r_bash
Reddit
r/bash on Reddit: Help with a bash noscript which uses variables and sed
Posted by u/HerefortheLAN - No votes and no comments
combining here-docs with process substitution
Hi,
I cannot figure out how to do this properly...
What I want is to generate a config-file on the fly and feed it to another program without writing any temporary files.
Here is an example for lighttpd that is supposed to serve the directory as supplied as argument:
ROOT=${1:-.}
/usr/sbin/lighttpd -f <(cat <<END
server.document-root = "$ROOT"
server.errorlog = "/tmp/lighty.log"
server.pid-file = "/tmp/lighty.pid"
server.port = 8080
server.dir-listing = "enable"
dir-listing.encoding = "utf-8"
END
) -D
This is syntactically correct, however something is wrong as lighttpd complains about document-root not being set...
Can someone help me out here?
Many thanks!
https://redd.it/11wysi0
@r_bash
Hi,
I cannot figure out how to do this properly...
What I want is to generate a config-file on the fly and feed it to another program without writing any temporary files.
Here is an example for lighttpd that is supposed to serve the directory as supplied as argument:
ROOT=${1:-.}
/usr/sbin/lighttpd -f <(cat <<END
server.document-root = "$ROOT"
server.errorlog = "/tmp/lighty.log"
server.pid-file = "/tmp/lighty.pid"
server.port = 8080
server.dir-listing = "enable"
dir-listing.encoding = "utf-8"
END
) -D
This is syntactically correct, however something is wrong as lighttpd complains about document-root not being set...
Can someone help me out here?
Many thanks!
https://redd.it/11wysi0
@r_bash
Reddit
r/bash on Reddit: combining here-docs with process substitution
Posted by u/ghiste - No votes and 1 comment
Sharness 1.2.0 released
Sharness is a test harness written in shell noscript with an output compatible with the Test Anything Protocol.
It was derived from the testing framework used in the Git project.
Writing test noscripts is extremely simple:
If you run this noscript, you get a TAP-compatible output:
You can write a target in your
Because it's written in shell, it's easy for anyone who knows shell to write test noscripts. If you know shell, you know Sharness.
Here's an example run of me running the test noscripts of multiple projects on asciinema: Sharness run.
For more information check the Sharness site.
If you are using Arch Linux, you can use the AUR package I created: sharness.
Enjoy!
https://redd.it/11x72p4
@r_bash
Sharness is a test harness written in shell noscript with an output compatible with the Test Anything Protocol.
It was derived from the testing framework used in the Git project.
Writing test noscripts is extremely simple:
test_denoscription='Basic tests'
. ./sharness.sh
test_expect_success 'Success expected' ':'
test_expect_success 'Chained commands' '
echo foo > file &&
echo bar >> file &&
test -s file
'
test_expect_failure 'Failure expected' 'test 1 = 2'
test_done
If you run this noscript, you get a TAP-compatible output:
ok 1 - Success expected
ok 2 - Chained commands
not ok 3 - Failure expected # TODO known breakage
# still have 1 known breakage(s)
# passed all remaining 2 test(s)
1..3
You can write a target in your
Makefile to execute them all or run prove, which executes all your test files in parallel.Because it's written in shell, it's easy for anyone who knows shell to write test noscripts. If you know shell, you know Sharness.
Here's an example run of me running the test noscripts of multiple projects on asciinema: Sharness run.
For more information check the Sharness site.
If you are using Arch Linux, you can use the AUR package I created: sharness.
Enjoy!
https://redd.it/11x72p4
@r_bash
Parser for Command Line Interface Pages is ready for usage
This [parser](https://github.com/command-line-interface-pages/v2-tooling/tree/main/clip-parse) is completely Bash + Sed-based. It allows extracting info about page easily and not to deal with Sed directly, delegating such business for a parser. As parser doesn't built AST, it's a little bit limited.
Let's say we have some page for a command [\[](https://github.com/command-line-interface-pages/cli-pages/blob/main/common/%5B.clip) and want to extract command denoscription. To do so, we have to write this code:
#!/usr/bin/env bash
# shellcheck source=/home/emilyseville7cfg/.local/bin/clip-parse
source clip-parse
# shellcheck disable=2016
declare page='# [
> Check file types and compare values
> Returns 0 if the condition evaluates to true, 1 if it evaluates to false
> More information: https://www.gnu.org/software/bash/manual/bash.html#index-test
- Test if a specific variable is (equal|not equal) to a string:
`[ "{string $variable: $foo}" {string operator: ==|string operator !=} "{string string: Hello world!}" ]`'
parser_summary__denoscription_prettified "$page"
​
https://preview.redd.it/zqlxdlddx1pa1.png?width=1920&format=png&auto=webp&v=enabled&s=e0b3ab644abff8624820c3edd20b03466755ec1e
https://preview.redd.it/oq1q32tgx1pa1.png?width=1920&format=png&auto=webp&v=enabled&s=bd70cd3754f35f10a7523909c6c7f52a278342de
To [install](https://github.com/command-line-interface-pages/v2-tooling/tree/main/clip-parse#installation-smile) the parser `make` should be available on your PC (now I support just it, but think about supporting another build systems too).
https://redd.it/11xatx7
@r_bash
This [parser](https://github.com/command-line-interface-pages/v2-tooling/tree/main/clip-parse) is completely Bash + Sed-based. It allows extracting info about page easily and not to deal with Sed directly, delegating such business for a parser. As parser doesn't built AST, it's a little bit limited.
Let's say we have some page for a command [\[](https://github.com/command-line-interface-pages/cli-pages/blob/main/common/%5B.clip) and want to extract command denoscription. To do so, we have to write this code:
#!/usr/bin/env bash
# shellcheck source=/home/emilyseville7cfg/.local/bin/clip-parse
source clip-parse
# shellcheck disable=2016
declare page='# [
> Check file types and compare values
> Returns 0 if the condition evaluates to true, 1 if it evaluates to false
> More information: https://www.gnu.org/software/bash/manual/bash.html#index-test
- Test if a specific variable is (equal|not equal) to a string:
`[ "{string $variable: $foo}" {string operator: ==|string operator !=} "{string string: Hello world!}" ]`'
parser_summary__denoscription_prettified "$page"
​
https://preview.redd.it/zqlxdlddx1pa1.png?width=1920&format=png&auto=webp&v=enabled&s=e0b3ab644abff8624820c3edd20b03466755ec1e
https://preview.redd.it/oq1q32tgx1pa1.png?width=1920&format=png&auto=webp&v=enabled&s=bd70cd3754f35f10a7523909c6c7f52a278342de
To [install](https://github.com/command-line-interface-pages/v2-tooling/tree/main/clip-parse#installation-smile) the parser `make` should be available on your PC (now I support just it, but think about supporting another build systems too).
https://redd.it/11xatx7
@r_bash
GitHub
v2-tooling/clip-parse at main · command-line-interface-pages/v2-tooling
Tools for handling v2.*.* syntax. Contribute to command-line-interface-pages/v2-tooling development by creating an account on GitHub.
(standard_in) 1 syntax error
i am doing
​
declare gen_rate=0.9721 declare trans=0.1122 declare sys_pass=0.0851 declare distri=0.1718 declare subs=0.4694 declare government_tax=0.0988 declare uni_rate=0.0294 basic_charge=$(echo "$basic_rate * $kwh_used" | bc) gen_charge=$(echo "$gen_rate * $basic_charge" | bc) trans_charge=$(echo "$trans * $basic_charge" | bc) sys_charge=$(echo "$sys_pass * $basic_charge" | bc) distri_charge=$(echo "$distri * $basic_charge" | bc) subs_charge=$(echo "$subs * $basic_charge" | bc) gov_charge=$(echo "$governmnet_tax * $basic_charge" | bc) uni_charge=$( echo "$uni_rate * $basic_charge" | bc) totalWater=$(echo "$basic_charge + $gen_charge + $trans_charge + $sys_charge + $distri_charge + $subs_charge + $government_charge + $uni_charge" | bc)```
https://redd.it/11xjdf9
@r_bash
i am doing
​
declare gen_rate=0.9721 declare trans=0.1122 declare sys_pass=0.0851 declare distri=0.1718 declare subs=0.4694 declare government_tax=0.0988 declare uni_rate=0.0294 basic_charge=$(echo "$basic_rate * $kwh_used" | bc) gen_charge=$(echo "$gen_rate * $basic_charge" | bc) trans_charge=$(echo "$trans * $basic_charge" | bc) sys_charge=$(echo "$sys_pass * $basic_charge" | bc) distri_charge=$(echo "$distri * $basic_charge" | bc) subs_charge=$(echo "$subs * $basic_charge" | bc) gov_charge=$(echo "$governmnet_tax * $basic_charge" | bc) uni_charge=$( echo "$uni_rate * $basic_charge" | bc) totalWater=$(echo "$basic_charge + $gen_charge + $trans_charge + $sys_charge + $distri_charge + $subs_charge + $government_charge + $uni_charge" | bc)```
https://redd.it/11xjdf9
@r_bash
Reddit
r/bash on Reddit: (standard_in) 1 syntax error
Posted by u/blushingseoks - No votes and no comments
I Created a Bash Script and I'm not getting the Output I wanted
So, I made a noscript to be integrated in a Cron Task, running in 5 minute intervals, with the objective of listening to a log file that is created daily, searching for a defined pattern. I have made it in a way that everytime the noscript is executed, it reads the file based on a .flag file that saves the last line read from the log file.
After running the noscript, I see that it didn't do what it was intended and the .flag file only has a 0 written in it.
My Script:
#!/bin/bash
LASTPOSFILE="lastposition.flag"
PATTERN='ERROR [pt.gsoft.oasis.platform.plugins.mediaconverter.ejb.messages.MediaConverterMDB]'
LOGFILE='/home/filipe/server.log'
if ! -f "$LAST_POS_FILE" ; then
echo 0 > "$LASTPOSFILE"
fi
LASTPOS=$(cat "$LASTPOSFILE")
CURRLOG=$(date +"%Y-%m-%d")
if "$LOG_FILE.$CURR_LOG" -nt "$LOG_FILE" ; then
LOGFILE="$LOGFILE.$CURRLOG"
fi
if [[ "$LOGFILE" -nt "$LOGFILE" ]]; then
LINE=$(grep -E "$PATTERN" "$LOGFILE" | awk -F: '{print $1}')
if -n "$LINE" ; then
if "$LINE" -gt "$LAST_POS" ; then
echo "$LINE" > "$LASTPOSFILE"
./teste.sh
fi
fi
fi
# end of file #
Another thing is that, I'm testing on a Ubuntu machine, since I don't have a testing environment for the production machine and the production machine is running Red-Hat, if that something important to have in account.
https://redd.it/11xkqli
@r_bash
So, I made a noscript to be integrated in a Cron Task, running in 5 minute intervals, with the objective of listening to a log file that is created daily, searching for a defined pattern. I have made it in a way that everytime the noscript is executed, it reads the file based on a .flag file that saves the last line read from the log file.
After running the noscript, I see that it didn't do what it was intended and the .flag file only has a 0 written in it.
My Script:
#!/bin/bash
LASTPOSFILE="lastposition.flag"
PATTERN='ERROR [pt.gsoft.oasis.platform.plugins.mediaconverter.ejb.messages.MediaConverterMDB]'
LOGFILE='/home/filipe/server.log'
if ! -f "$LAST_POS_FILE" ; then
echo 0 > "$LASTPOSFILE"
fi
LASTPOS=$(cat "$LASTPOSFILE")
CURRLOG=$(date +"%Y-%m-%d")
if "$LOG_FILE.$CURR_LOG" -nt "$LOG_FILE" ; then
LOGFILE="$LOGFILE.$CURRLOG"
fi
if [[ "$LOGFILE" -nt "$LOGFILE" ]]; then
LINE=$(grep -E "$PATTERN" "$LOGFILE" | awk -F: '{print $1}')
if -n "$LINE" ; then
if "$LINE" -gt "$LAST_POS" ; then
echo "$LINE" > "$LASTPOSFILE"
./teste.sh
fi
fi
fi
# end of file #
Another thing is that, I'm testing on a Ubuntu machine, since I don't have a testing environment for the production machine and the production machine is running Red-Hat, if that something important to have in account.
https://redd.it/11xkqli
@r_bash
Reddit
r/bash on Reddit: I Created a Bash Script and I'm not getting the Output I wanted
Posted by u/Nome_Roubado - No votes and 4 comments
Does anyone else get by using ctrl + r 90% of the time?
Honestly, this bash command is the great majority of what I do to as a senior full stack developer using bash. Can anyone else relate?
https://redd.it/11xw5zb
@r_bash
Honestly, this bash command is the great majority of what I do to as a senior full stack developer using bash. Can anyone else relate?
https://redd.it/11xw5zb
@r_bash
Reddit
r/bash on Reddit: Does anyone else get by using ctrl + r 90% of the time?
Posted by u/UncleFoster - No votes and 1 comment
Help with Email Suppression Script from Command Line (Unix / Linux / macOS)
Enter the following in the macOS Terminal App:
./suppress.sh FileA FileB > FileC
​
A friend created this custom noscript for me circa 2010 to solve a problem I had with email marketing. If I had List A that needed to be sent to, but I also had List B of people who should not receive the email, the noscript would create List C, which was made by taking List A and then subtracting the contents of List B. (List C = List A - List B). It was designed to work specifically with email addresses, but I suppose it would work fine for single words on a line.
​
It used to work fine, but I haven't used it in a while and there appears to have been enough changes in macOS that it needs a bit of love. Can anyone help with the required updates to make it work? Please see example below.
​
EXAMPLE
LIST A (original list)
\---------------------------------------------
one@gmail.com
two@gmail.com
three@gmail.com
four@gmail.com
five@gmail.com
six@gmail.com
seven@gmail.com
eight@gmail.com
nine@gmail.com
ten@gmail.com
LIST B (list of emails to suppress)
\---------------------------------------------
one@gmail.com
three@gmail.com
five@gmail.com
seven@gmail.com
nine@gmail.com
when run, it would create List C which would look like below
LIST C (new list of A-B)
\---------------------------------------------
two@gmail.com
four@gmail.com
six@gmail.com
eight@gmail.com
ten@gmail.com
https://redd.it/11xvb91
@r_bash
#!/bin/bash(sed 's/^/A /' $1;sed 's/^/B /' $2)|sort -fk 2|uniq -ius 2|sed -ne '/^B /d' -e 's/^A //p'Enter the following in the macOS Terminal App:
./suppress.sh FileA FileB > FileC
​
A friend created this custom noscript for me circa 2010 to solve a problem I had with email marketing. If I had List A that needed to be sent to, but I also had List B of people who should not receive the email, the noscript would create List C, which was made by taking List A and then subtracting the contents of List B. (List C = List A - List B). It was designed to work specifically with email addresses, but I suppose it would work fine for single words on a line.
​
It used to work fine, but I haven't used it in a while and there appears to have been enough changes in macOS that it needs a bit of love. Can anyone help with the required updates to make it work? Please see example below.
​
EXAMPLE
LIST A (original list)
\---------------------------------------------
one@gmail.com
two@gmail.com
three@gmail.com
four@gmail.com
five@gmail.com
six@gmail.com
seven@gmail.com
eight@gmail.com
nine@gmail.com
ten@gmail.com
LIST B (list of emails to suppress)
\---------------------------------------------
one@gmail.com
three@gmail.com
five@gmail.com
seven@gmail.com
nine@gmail.com
when run, it would create List C which would look like below
LIST C (new list of A-B)
\---------------------------------------------
two@gmail.com
four@gmail.com
six@gmail.com
eight@gmail.com
ten@gmail.com
https://redd.it/11xvb91
@r_bash
Reddit
r/bash on Reddit: Help with Email Suppression Script from Command Line (Unix / Linux / macOS)
Posted by u/RobertoVerdeNYC - No votes and 3 comments
please help!
I have a noscript that just sets up Fedora server and a WM but that is not relevant.
the problem is that the fonts do not download to home or unzip to .fonts/truetype. Here is the code snippet
Please ignore the formatting it did not get copied over correctly.
https://redd.it/11y3tzr
@r_bash
I have a noscript that just sets up Fedora server and a WM but that is not relevant.
the problem is that the fonts do not download to home or unzip to .fonts/truetype. Here is the code snippet
while true; doread -p "Would you like to install JetBrainsMono nerd font Y/N " fontinstcase $fontinst iny|Y ) echo "# Adding Nerd fonts to "$HOME"/.fonts/truetype #"; mkdir"$HOME"/.fonts/truetype; wget-q `https://github.com/ryanoasis/nerd-`fonts/releases/download/v2.3.3/JetBrainsMono.zip;unzip "$HOME"/JetBrainsMono.zip -d "$HOME"/.fonts/truetype;;n|N ) echo "Aborted, skipping..."esacdonePlease ignore the formatting it did not get copied over correctly.
https://redd.it/11y3tzr
@r_bash
5 Bash Coding Techniques That Every Programmer Should Know
https://levelup.gitconnected.com/5-bash-coding-techniques-that-every-programmer-should-know-f63b11b59e8d?sk=68bacc0a0f27df6e910dcd0352c05f76
https://redd.it/11ya6ab
@r_bash
https://levelup.gitconnected.com/5-bash-coding-techniques-that-every-programmer-should-know-f63b11b59e8d?sk=68bacc0a0f27df6e910dcd0352c05f76
https://redd.it/11ya6ab
@r_bash
Medium
5 Bash Coding Techniques That Every Programmer Should Know
Use these coding techniques to write fast and readable shell noscripts
Need help idk what to try anymore I don’t know how to code really
i have no idea how to code but i need help
i run a Minecraft server for me and some friends and i wanted to add an automatic restart i have worked with chat gtp to try and add this but it wont work here are some we tried. this is in windows 11 CMD. i have more version i have tried but i didn't save them. plz help
START CODE THAT WORKS/original code
echo off
call settings.bat
:start_server
echo Starting SevTech Ages Server...
java -server -Xms1024M -Xmx25600M %JAVA_PARAMETERS% -jar %SERVER_JAR% nogui
pause
exit /B
goto start_server
\---------------------------------------------------------------------------------------
here's some I have tried
\---------------------------------------------------------------------------------------
echo off
call settings.bat
:start_server
echo Starting SevTech Ages Server...
java -server -Xms1024M -Xmx25600M %JAVA_PARAMETERS% -jar %SERVER_JAR% nogui
pause
exit /B
REM Timer to announce server restart
set /a counter=0
:timer_loop
set /a counter+=1
if %counter% equ 28800 (
echo SERVER RESTARTING IN 10 MINS
echo [1m [33mSERVER RESTARTING IN 10 MINS [0m
timeout /t 600
call :restart_server
) else (
timeout /t 60
goto timer_loop
)
REM Function to stop and restart server
:restart_server
echo Stopping SevTech Ages Server...
taskkill /f /im java.exe
echo SevTech Ages Server has been stopped.
echo Restarting SevTech Ages Server...
java -server -Xms1024M -Xmx25600M %JAVA_PARAMETERS% -jar %SERVER_JAR% nogui
echo SevTech Ages Server has been restarted.
goto start_server
\------------------------------------------------------------------------------------------------------------------
echo off
call settings.bat
:start_server
echo Starting SevTech Ages Server...
java -server -Xms1024M -Xmx25600M %JAVA_PARAMETERS% -jar %SERVER_JAR% nogui
pause
exit /B
REM Add timer for server restart
set "colors=1 3 4 6 2 5"
set "color_index=0"
for /l %%x in (1,1,28800) do (
if %%x==1 (
echo \^[[1;32;47mServer started. Starting timer...\^[[0m
)
if %%x==28800 (
for %%c in (%colors%) do (
set /a "color_index=(color_index+1)%%6"
echo \^[[1;%color_index%;47mSERVER RESTARTING IN 10 MINS\^[[0m
timeout /t 10 /nobreak > nul
)
echo \^[[1;31;47mSERVER RESTARTING NOW\^[[0m
taskkill /f /im java.exe > nul
java -server -Xms1024M -Xmx25600M %JAVA_PARAMETERS% -jar %SERVER_JAR% nogui
)
)
https://redd.it/11ye68j
@r_bash
i have no idea how to code but i need help
i run a Minecraft server for me and some friends and i wanted to add an automatic restart i have worked with chat gtp to try and add this but it wont work here are some we tried. this is in windows 11 CMD. i have more version i have tried but i didn't save them. plz help
START CODE THAT WORKS/original code
echo off
call settings.bat
:start_server
echo Starting SevTech Ages Server...
java -server -Xms1024M -Xmx25600M %JAVA_PARAMETERS% -jar %SERVER_JAR% nogui
pause
exit /B
goto start_server
\---------------------------------------------------------------------------------------
here's some I have tried
\---------------------------------------------------------------------------------------
echo off
call settings.bat
:start_server
echo Starting SevTech Ages Server...
java -server -Xms1024M -Xmx25600M %JAVA_PARAMETERS% -jar %SERVER_JAR% nogui
pause
exit /B
REM Timer to announce server restart
set /a counter=0
:timer_loop
set /a counter+=1
if %counter% equ 28800 (
echo SERVER RESTARTING IN 10 MINS
echo [1m [33mSERVER RESTARTING IN 10 MINS [0m
timeout /t 600
call :restart_server
) else (
timeout /t 60
goto timer_loop
)
REM Function to stop and restart server
:restart_server
echo Stopping SevTech Ages Server...
taskkill /f /im java.exe
echo SevTech Ages Server has been stopped.
echo Restarting SevTech Ages Server...
java -server -Xms1024M -Xmx25600M %JAVA_PARAMETERS% -jar %SERVER_JAR% nogui
echo SevTech Ages Server has been restarted.
goto start_server
\------------------------------------------------------------------------------------------------------------------
echo off
call settings.bat
:start_server
echo Starting SevTech Ages Server...
java -server -Xms1024M -Xmx25600M %JAVA_PARAMETERS% -jar %SERVER_JAR% nogui
pause
exit /B
REM Add timer for server restart
set "colors=1 3 4 6 2 5"
set "color_index=0"
for /l %%x in (1,1,28800) do (
if %%x==1 (
echo \^[[1;32;47mServer started. Starting timer...\^[[0m
)
if %%x==28800 (
for %%c in (%colors%) do (
set /a "color_index=(color_index+1)%%6"
echo \^[[1;%color_index%;47mSERVER RESTARTING IN 10 MINS\^[[0m
timeout /t 10 /nobreak > nul
)
echo \^[[1;31;47mSERVER RESTARTING NOW\^[[0m
taskkill /f /im java.exe > nul
java -server -Xms1024M -Xmx25600M %JAVA_PARAMETERS% -jar %SERVER_JAR% nogui
)
)
https://redd.it/11ye68j
@r_bash
Reddit
r/bash on Reddit: Need help idk what to try anymore I don’t know how to code really
Posted by u/bulldog44zz - No votes and 1 comment