I made a CLI to use saved curl requests
I'm slowly going from using GUI apps to just CLI/TUI and while doing that I wanted to ditch Postman as the app I use to test my apis. Looked through a couple of them but none was what I wanted so I made this one.
I'ts called Curlier and it runs .sh files with the curl request inside of it. It's handy cause I can do whatever I want to the curl response inside my .sh file allowing me to just do curly <request_name> and getting the reponse parsed as I want (or whatever I want to do with it tbh).
Idk, felt like sharing it here for people to try it out, contribute and tell me what they think about it.
Kinda new to shell noscripting so be kind.
https://redd.it/1k6im99
@r_bash
I'm slowly going from using GUI apps to just CLI/TUI and while doing that I wanted to ditch Postman as the app I use to test my apis. Looked through a couple of them but none was what I wanted so I made this one.
I'ts called Curlier and it runs .sh files with the curl request inside of it. It's handy cause I can do whatever I want to the curl response inside my .sh file allowing me to just do curly <request_name> and getting the reponse parsed as I want (or whatever I want to do with it tbh).
Idk, felt like sharing it here for people to try it out, contribute and tell me what they think about it.
Kinda new to shell noscripting so be kind.
https://redd.it/1k6im99
@r_bash
GitHub
GitHub - F2BEAR/curlier: A minimal, extensible, and flexible CLI tool to execute saved requests using curl.
A minimal, extensible, and flexible CLI tool to execute saved requests using curl. - F2BEAR/curlier
What's a Bash command or concept that took you way too long to learn, but now you can't live without?
For me, it was using
https://redd.it/1k6n0v5
@r_bash
For me, it was using
xargs properly, once it clicked, it completely changed how I write noscripts. Would love to hear your “Aha!” moments and what finally made things click!https://redd.it/1k6n0v5
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Is it possible that RSYNC lists all the directories to say that it passes for all of them?
Hello! (thanks to ~~goog~~... translator)
Is it possible that RSYNC lists all the directories to say that it passes for all of them to see if there was something inside them that has changed?
I clarify that I am using RSYNC with origin = Linux and destination (a pendrive) with Fat32.
and finally verbose say that the copy will be small weight something like equiv. to about 1 common.jpg (little transfer little copy).
See this screenshot for see the list o dirs with and without files into them...
of course I understand that dirs below are listed because they have newer files to copy, but upper them, the list is only of dirs.
https://imgbox.com/WoKhKR20
I am testing an SD formatted with Ext4 to try how RSYNC works with Linux origin and destination in both cases.
And in this case of a modest test with few test directories, when I do RSYNC, RSYNc does not list the directories, that is, it does not warn me that I pass through the directories of this small Linux Test Origin Destination (Ext4).
Thanks and greetings!
https://redd.it/1k6rg7h
@r_bash
Hello! (thanks to ~~goog~~... translator)
Is it possible that RSYNC lists all the directories to say that it passes for all of them to see if there was something inside them that has changed?
I clarify that I am using RSYNC with origin = Linux and destination (a pendrive) with Fat32.
and finally verbose say that the copy will be small weight something like equiv. to about 1 common.jpg (little transfer little copy).
See this screenshot for see the list o dirs with and without files into them...
of course I understand that dirs below are listed because they have newer files to copy, but upper them, the list is only of dirs.
https://imgbox.com/WoKhKR20
I am testing an SD formatted with Ext4 to try how RSYNC works with Linux origin and destination in both cases.
And in this case of a modest test with few test directories, when I do RSYNC, RSYNc does not list the directories, that is, it does not warn me that I pass through the directories of this small Linux Test Origin Destination (Ext4).
Thanks and greetings!
https://redd.it/1k6rg7h
@r_bash
Imgbox
imgbox - fast, simple image host
Use imgbox to upload, host and share all your images. It's simple, free and blazing fast!
Script works locally not when curl is used
I have a noscript that requires a y/n response that works when run locally, but when I curl it it seems as if a random character is passed:
Script `test.sh`:
#!/bin/bash
while true; do
read -p "Do you want to proceed? (Yn) " yn
case $yn in
[Y] ) echo ok, we will proceed;
break;;
[n] ) echo exiting...;
exit;;
* ) echo invalid response;;
esac
done
echo doing stuff...
df -hT
Whenever I use curl like this:
`curl -sSL https://url.com/test.sh | bash -x`
Then I get:
+ true
+ read -p 'Do you want to proceed? (Yn) ' yn
+ case $yn in
+ echo invalid response
invalid response
+ true
+ read -p 'Do you want to proceed? (Yn) ' yn
+ case $yn in
+ echo invalid response
invalid response
+ true
+ read -p 'Do you want to proceed? (Yn) ' yn
+ case $yn in
+ echo invalid response
invalid response
+ true
+ read -p 'Do you want to proceed? (Yn) ' yn
+ case $yn in
+ echo invalid response
invalid response
+ true
+ read -p 'Do you want to proceed? (Yn) ' yn
+ case $yn in
+ echo invalid response
invalid response
It seems as a character is passed continually. What is going wrong here? I really have no idea. Same noscript locally and curl.
https://redd.it/1k6umwg
@r_bash
I have a noscript that requires a y/n response that works when run locally, but when I curl it it seems as if a random character is passed:
Script `test.sh`:
#!/bin/bash
while true; do
read -p "Do you want to proceed? (Yn) " yn
case $yn in
[Y] ) echo ok, we will proceed;
break;;
[n] ) echo exiting...;
exit;;
* ) echo invalid response;;
esac
done
echo doing stuff...
df -hT
Whenever I use curl like this:
`curl -sSL https://url.com/test.sh | bash -x`
Then I get:
+ true
+ read -p 'Do you want to proceed? (Yn) ' yn
+ case $yn in
+ echo invalid response
invalid response
+ true
+ read -p 'Do you want to proceed? (Yn) ' yn
+ case $yn in
+ echo invalid response
invalid response
+ true
+ read -p 'Do you want to proceed? (Yn) ' yn
+ case $yn in
+ echo invalid response
invalid response
+ true
+ read -p 'Do you want to proceed? (Yn) ' yn
+ case $yn in
+ echo invalid response
invalid response
+ true
+ read -p 'Do you want to proceed? (Yn) ' yn
+ case $yn in
+ echo invalid response
invalid response
It seems as a character is passed continually. What is going wrong here? I really have no idea. Same noscript locally and curl.
https://redd.it/1k6umwg
@r_bash
MediaOptions
URL.com - MediaOptions
URL.com is a sought-after domain that MediaOptions can help broker for you. Contact us today to get the domain name your company needs!
Need help running automatic command on terminal
As noscript says, first of all I am new to this. I need help (not sure which MacOS terminal I should even begin with- the basic one that it comes with, iTerm2, or Tabby)
I am trying to run a sha512 hash command that will generate a seed. But I need to do it automated- way faster than manually typing. I need to run the command about 100,000 times.
The command I need to use: echo -n "1710084026-4b0f5fc279ba41b3e6d6b73fb26b8b333a1c3b7963a4c5b03f412538596b440c-UYwqnEx6DT9L-Number: 50796" |sha512sum
Which generates the seed: 312e1a1f5e194adfa429fefc001d2d01ea41d96591ae9fbbd59ab7f04a541f4d658440163142908d97a6c083b37482ab6565d9d212a95c58fab9a19589244a41
Now, I need to also change the "Number" value each time I run the command, so the seed generated changes obviously. For example, listed above is "50796", and I would need to change each time, lets say the second number I would test next would be "40048".
That would give the generated seed of:
885120a467d71ec6e14964e9898eb2ac1c49060945665d74665564bf075bbf6919ef886f37d3843993452092bcbcd39945e4774f252edd3dbfc2c6f7823af890
I need to do this for about 100,000 different numbers, until I get the seed match I am looking for. I have 120 characters for the hash seed im looking for, but missing the last 8.
I don't even know if I'm In the right place to post this, or what subreddit to do. But I desperately need help with this.
So far, I have this:
\#!/bin/bash
start_number=0
end_number=100000
target_seed="30b842d3b1c1fcf6eb24bc06f64b7d9733106633bbd98c66bda1365466a044580d0a452500397252ff4d129d17404a5ee244e0c42bab5624e86a423a"
echo "Searching for target seed pattern in range $start_number to $end_number..."
echo "Target pattern: $target_seed"
echo ""
found=false
for ((num=start_number; num<=end_number; num++)); do
\# Generate the seed
seed=$(echo -n "1710084026-4b0f5fc279ba41b3e6d6b73fb26b8b333a1c3b7963a4c5b03f412538596b440c-UYwqnEx6DT9L-Number: $num" | sha512sum | awk '{print $1}')
\# Display progress every 1000 iterations
if (( num % 1000 == 0 )); then
echo -ne "Checked: $num | Current seed: $seed\\r"
fi
\# Check for match
if [[ "$seed" == "$target_seed" \]\]; then
echo -e "\\n\\nMATCH FOUND!"
echo "Number: $num"
echo "Seed: $seed"
found=true
break
fi
done
if [[ "$found" == false \]\]; then
echo -e "\\n\\nNo match found in the specified range."
fi
But I haven't had matches, or I am doing something improperly. Does anyone have any help they could show me or point me to the right direction? Thank you so much!
https://redd.it/1k86if3
@r_bash
As noscript says, first of all I am new to this. I need help (not sure which MacOS terminal I should even begin with- the basic one that it comes with, iTerm2, or Tabby)
I am trying to run a sha512 hash command that will generate a seed. But I need to do it automated- way faster than manually typing. I need to run the command about 100,000 times.
The command I need to use: echo -n "1710084026-4b0f5fc279ba41b3e6d6b73fb26b8b333a1c3b7963a4c5b03f412538596b440c-UYwqnEx6DT9L-Number: 50796" |sha512sum
Which generates the seed: 312e1a1f5e194adfa429fefc001d2d01ea41d96591ae9fbbd59ab7f04a541f4d658440163142908d97a6c083b37482ab6565d9d212a95c58fab9a19589244a41
Now, I need to also change the "Number" value each time I run the command, so the seed generated changes obviously. For example, listed above is "50796", and I would need to change each time, lets say the second number I would test next would be "40048".
That would give the generated seed of:
885120a467d71ec6e14964e9898eb2ac1c49060945665d74665564bf075bbf6919ef886f37d3843993452092bcbcd39945e4774f252edd3dbfc2c6f7823af890
I need to do this for about 100,000 different numbers, until I get the seed match I am looking for. I have 120 characters for the hash seed im looking for, but missing the last 8.
I don't even know if I'm In the right place to post this, or what subreddit to do. But I desperately need help with this.
So far, I have this:
\#!/bin/bash
start_number=0
end_number=100000
target_seed="30b842d3b1c1fcf6eb24bc06f64b7d9733106633bbd98c66bda1365466a044580d0a452500397252ff4d129d17404a5ee244e0c42bab5624e86a423a"
echo "Searching for target seed pattern in range $start_number to $end_number..."
echo "Target pattern: $target_seed"
echo ""
found=false
for ((num=start_number; num<=end_number; num++)); do
\# Generate the seed
seed=$(echo -n "1710084026-4b0f5fc279ba41b3e6d6b73fb26b8b333a1c3b7963a4c5b03f412538596b440c-UYwqnEx6DT9L-Number: $num" | sha512sum | awk '{print $1}')
\# Display progress every 1000 iterations
if (( num % 1000 == 0 )); then
echo -ne "Checked: $num | Current seed: $seed\\r"
fi
\# Check for match
if [[ "$seed" == "$target_seed" \]\]; then
echo -e "\\n\\nMATCH FOUND!"
echo "Number: $num"
echo "Seed: $seed"
found=true
break
fi
done
if [[ "$found" == false \]\]; then
echo -e "\\n\\nNo match found in the specified range."
fi
But I haven't had matches, or I am doing something improperly. Does anyone have any help they could show me or point me to the right direction? Thank you so much!
https://redd.it/1k86if3
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
I know that cp does not have --exclude=this_dir/ ... but I like exclude any (only 1) subdir/
**Hi**, How can I copy a dir/ excluding only 1 subdir/ of a dir/ in this alias:
fecha="cp -r ../parcial/ ./$(date +%y%m%d)"
dir/ is ../parcial/ and exclude subdir/ is "some_subdir_name/"
Thank you and regards!
https://redd.it/1k8fs31
@r_bash
**Hi**, How can I copy a dir/ excluding only 1 subdir/ of a dir/ in this alias:
fecha="cp -r ../parcial/ ./$(date +%y%m%d)"
dir/ is ../parcial/ and exclude subdir/ is "some_subdir_name/"
Thank you and regards!
https://redd.it/1k8fs31
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
On my system, why do some commands print their output in a read-only mode that ends with (END), which I have to leave with a any-keypress? What is this and how can I turn this off once and for all?
noscript
https://redd.it/1k91qur
@r_bash
noscript
https://redd.it/1k91qur
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Efficiently delete a block of text containing a line matching regex pattern
File in the format:
General
StartWithLastProfile=1
Profile0
Name=default
IsRelative=1
Path=Profiles/default.cta
Profile1
Name=alicew
IsRelative=0
Path=D:\Mozilla\Firefox\Profiles\alicew
Default=1
Profile2
Name=sheldon
IsRelative=0
Path=D:\Mozilla\Firefox\Profiles\sheldon
How to delete entire block of text (delimited by an empty line) if line matches
General
StartWithLastProfile=1
Profile0
Name=default
IsRelative=1
Path=Profiles/default.cta
Profile2
Name=sheldon
IsRelative=0
Path=D:\Mozilla\Firefox\Profiles\sheldon
Preferably efficiently (i.e. requires only reading the file once) and in something relatively easy to understand and extend like awk or bash.
https://redd.it/1k9msmj
@r_bash
File in the format:
General
StartWithLastProfile=1
Profile0
Name=default
IsRelative=1
Path=Profiles/default.cta
Profile1
Name=alicew
IsRelative=0
Path=D:\Mozilla\Firefox\Profiles\alicew
Default=1
Profile2
Name=sheldon
IsRelative=0
Path=D:\Mozilla\Firefox\Profiles\sheldon
How to delete entire block of text (delimited by an empty line) if line matches
Name=alicew? It can be assumed there's only one unique match. So the file should be overwritten as:General
StartWithLastProfile=1
Profile0
Name=default
IsRelative=1
Path=Profiles/default.cta
Profile2
Name=sheldon
IsRelative=0
Path=D:\Mozilla\Firefox\Profiles\sheldon
Preferably efficiently (i.e. requires only reading the file once) and in something relatively easy to understand and extend like awk or bash.
https://redd.it/1k9msmj
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
inotify use cases, generic app reloader responding to config changes
I'm looking for a way to automatically/efficiently do things when certain files change. For example, reload the status bar or notification application when their config changes. `inotify` seems appropriate for that, checking for changes as events instead of constantly polling with e.g. `sleep 1` in an indefinite loop (if the info you're looking to update changes rarely, the former would be much more efficient).
* Is the following suitable for a generic app reloader on config change and can it be improved? `app_reloader` is the most app-specific part of the implementation--some apps take a signal to reload the config without restarting the process, but the "generic" way would be to simply restart the process.
# This specific example is hardcoded for `waybar`, can/should it work for any
apps in general?
app_config="$HOME/.config/waybar" # App's dir to check for changes
app_cmd() { exec waybar & } # Command to start app
# Reload app. Usually means kill process and start new instance, but in this
example with waybar, signal can be sent to simply reload the config without
restarting the process
app_reload() {
killall -u "$USER" -SIGUSR2 waybar
# Wait until the processes have been shut down
# while pgrep -u "$UID" -x waybar > /dev/null; do sleep 1; done
}
while true; do
pgrep -u "$UID" -x waybar &>/dev/null || app_cmd
# Exclude hidden files sometimes created by text editors as part of
# periodic autosaves which could trigger an unintended reload
inotifywait -e create,modify -r "$app_config" --exclude "$app_config/\."
app_reload
done
* Is it a good idea to make heavy use of inotify throughout the filesystem? For example, checking `~/downloads` for when files complete their downloads (e.g if a `.part*`,`aria2`, etc. file no longer exists) and updating that count on the on the status bar (or similarly, do a `du -sh` only when a file is finished downloading, as opposed to status bars typically polling every 3-30 seconds).
* Also interested in any other ideas to take advantage of `inotify`--it seems heavily underutilized for some reason.
https://redd.it/1k9xhsf
@r_bash
I'm looking for a way to automatically/efficiently do things when certain files change. For example, reload the status bar or notification application when their config changes. `inotify` seems appropriate for that, checking for changes as events instead of constantly polling with e.g. `sleep 1` in an indefinite loop (if the info you're looking to update changes rarely, the former would be much more efficient).
* Is the following suitable for a generic app reloader on config change and can it be improved? `app_reloader` is the most app-specific part of the implementation--some apps take a signal to reload the config without restarting the process, but the "generic" way would be to simply restart the process.
# This specific example is hardcoded for `waybar`, can/should it work for any
apps in general?
app_config="$HOME/.config/waybar" # App's dir to check for changes
app_cmd() { exec waybar & } # Command to start app
# Reload app. Usually means kill process and start new instance, but in this
example with waybar, signal can be sent to simply reload the config without
restarting the process
app_reload() {
killall -u "$USER" -SIGUSR2 waybar
# Wait until the processes have been shut down
# while pgrep -u "$UID" -x waybar > /dev/null; do sleep 1; done
}
while true; do
pgrep -u "$UID" -x waybar &>/dev/null || app_cmd
# Exclude hidden files sometimes created by text editors as part of
# periodic autosaves which could trigger an unintended reload
inotifywait -e create,modify -r "$app_config" --exclude "$app_config/\."
app_reload
done
* Is it a good idea to make heavy use of inotify throughout the filesystem? For example, checking `~/downloads` for when files complete their downloads (e.g if a `.part*`,`aria2`, etc. file no longer exists) and updating that count on the on the status bar (or similarly, do a `du -sh` only when a file is finished downloading, as opposed to status bars typically polling every 3-30 seconds).
* Also interested in any other ideas to take advantage of `inotify`--it seems heavily underutilized for some reason.
https://redd.it/1k9xhsf
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
comparing 2 sets of variables?
My code is unfortunately not working. It appears that it is only looking at the last 2 variables:
for reference a matches b and x matches y. I am attempting to compare the first 2 (I want a and b to match each other) and match the last 2 (I want x and y to match) if either set does not match, I want it to echo "no match".
if [[ "$a" == "$b" && "$x" == "$y" \]\];
then
echo "match"
else
echo "no match"
fi
https://redd.it/1kbkph0
@r_bash
My code is unfortunately not working. It appears that it is only looking at the last 2 variables:
for reference a matches b and x matches y. I am attempting to compare the first 2 (I want a and b to match each other) and match the last 2 (I want x and y to match) if either set does not match, I want it to echo "no match".
if [[ "$a" == "$b" && "$x" == "$y" \]\];
then
echo "match"
else
echo "no match"
fi
https://redd.it/1kbkph0
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Do you still write pure Bash, or do you mix in other tools?
At what point do you ditch Bash for Python, Go, or something else? Curious where others draw the line.
https://redd.it/1kbhtxo
@r_bash
At what point do you ditch Bash for Python, Go, or something else? Curious where others draw the line.
https://redd.it/1kbhtxo
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
orgsync - Keep your org files in sync across computers!
# orgsync
Hello everyone, after just 2 days of learning Bash I decided to get my hands dirty and start work on a project, one that would actually benefit me, and so I settled on
Initially, it started out from a need to facilitate syncing changes across my personal & work computers, both of which have different operating systems (MacOS & Windows), additionally, I recently had my work computer switched to a newer one, so I figured having an automated noscript that pulled my org repository and placed it in a previously defined location would be useful for future such cases.
Note that currently, on the Windows side of things, it only supports WSL, although msys support through Git Bash is something I want to implement.
The link to the repo is here: https://github.com/MiEdCaLe/orgsync
# Why?
Learning purposes, which is why it's in a very rough state and even though I realized halfway through that it might not be all that useful compared to just doing it manually, I learned a lot, and wanted to share it here!
https://redd.it/1kc0g8q
@r_bash
# orgsync
Hello everyone, after just 2 days of learning Bash I decided to get my hands dirty and start work on a project, one that would actually benefit me, and so I settled on
orgsync. orgsync is a Bash CLI tool that makes it easier to keep my Emacs org files synced across devices, regardless of the OS type.Initially, it started out from a need to facilitate syncing changes across my personal & work computers, both of which have different operating systems (MacOS & Windows), additionally, I recently had my work computer switched to a newer one, so I figured having an automated noscript that pulled my org repository and placed it in a previously defined location would be useful for future such cases.
Note that currently, on the Windows side of things, it only supports WSL, although msys support through Git Bash is something I want to implement.
The link to the repo is here: https://github.com/MiEdCaLe/orgsync
# Why?
Learning purposes, which is why it's in a very rough state and even though I realized halfway through that it might not be all that useful compared to just doing it manually, I learned a lot, and wanted to share it here!
https://redd.it/1kc0g8q
@r_bash
GitHub
GitHub - MiEdCaLe/orgsync: Bash CLI tool that automates syncing of Emacs "org" directories across computers, regardless of OS.
Bash CLI tool that automates syncing of Emacs "org" directories across computers, regardless of OS. - MiEdCaLe/orgsync
GitHub - nguyenanhung/infra-caddy-guy: A lightweight Server management noscript set, backend is Docker, Caddy Web Server. Makes the life of the infra guy a little simpler and easier.
https://github.com/nguyenanhung/infra-caddy-guy
https://redd.it/1kc72kz
@r_bash
https://github.com/nguyenanhung/infra-caddy-guy
https://redd.it/1kc72kz
@r_bash
GitHub
GitHub - nguyenanhung/infra-caddy-guy: A lightweight Server management noscript set, backend is Docker, Caddy Web Server. Makes the…
A lightweight Server management noscript set, backend is Docker, Caddy Web Server. Makes the life of the infra guy a little simpler and easier. - nguyenanhung/infra-caddy-guy
Mass renaming and moving of files according to file structure?
Hi,
I have a bunch of videos organised like this:
Videos
> Friends
> Season 1
> ep1.mp4
> ep2.mp4
> ep3.mp4
> Season 2
> ep1.mp4
> ep2.mp4
> ep3.mp4
> Season 3
> ep1.mp4
> ep2.mp4
> ep3.mp4
Now I want all files renamed according to file structure and moved to parent directory, like this:
Videos
> Friends_Season_1_ep1.mp4
Friends_Season_1_ep2.mp4
Friends_Season_1_ep3.mp4
Friends_Season_2_ep1.mp4
Friends_Season_2_ep2.mp4
Friends_Season_2_ep3.mp4
Friends_Season_3_ep1.mp4
Friends_Season_3_ep2.mp4
Friends_Season_3_ep3.mp4
How can I do that?
Thanks.
https://redd.it/1kc9g9p
@r_bash
Hi,
I have a bunch of videos organised like this:
Videos
> Friends
> Season 1
> ep1.mp4
> ep2.mp4
> ep3.mp4
> Season 2
> ep1.mp4
> ep2.mp4
> ep3.mp4
> Season 3
> ep1.mp4
> ep2.mp4
> ep3.mp4
Now I want all files renamed according to file structure and moved to parent directory, like this:
Videos
> Friends_Season_1_ep1.mp4
Friends_Season_1_ep2.mp4
Friends_Season_1_ep3.mp4
Friends_Season_2_ep1.mp4
Friends_Season_2_ep2.mp4
Friends_Season_2_ep3.mp4
Friends_Season_3_ep1.mp4
Friends_Season_3_ep2.mp4
Friends_Season_3_ep3.mp4
How can I do that?
Thanks.
https://redd.it/1kc9g9p
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
How to make
How to make
Example:
https://redd.it/1kcweni
@r_bash
false && false fail in Bash Strict Mode?How to make
false && false fail in Bash Strict Mode?Example:
#!/usr/bin/env bash
# Bash Strict Mode: https://github.com/guettli/bash-strict-mode
trap 'echo -e "\n🤷 🚨 🔥 Warning: A command has failed. Exiting the noscript. Line was ($0:$LINENO): $(sed -n "${LINENO}p" "$0" 2>/dev/null || true) 🔥 🚨 🤷 "; exit 3' ERR
set -Eeuo pipefail
false && false
echo foo
https://redd.it/1kcweni
@r_bash
Reddit
From the bash community on Reddit: How to make `false && false` fail in Bash Strict Mode?
Explore this post and more from the bash community
text variable manipulation without external commands
I wish to do the following within bash, no external programs.
I have a shell variable which FYI contains a snooker frame score. It looks like the 20 samples below. Let's call the shell variable score. It's a scalar variable.
13-67(63) 7-68(68) 80-1 10-89(85) 0-73(73) 3-99(63) 97(52)-22 113(113)-24 59(59)-60(60) 0-67(57) 1-97(97) 120(52,56)-27 108(54)-0 130(129)-4 128(87)-0 44-71(70) 87(81)-44 72(72)-0 0-130(52,56) 90(66)-12
So we have the 2 players score separated by a "-". On each side of the - is possibly 1 or 2 numbers (separated by comma) in brackets "()". None of the numbers are more than 3 digits. (snooker fans will know anything over 147 would be unusual).
From that scalar score, I want six numbers, which are:
1: player1 score
2: player2 score
3: first number is brackets for p1
4: second number in brackets for p1
5: first number is brackets for p2
6: second number in brackets for p2
If the number does not exist, set it to -1.
So to pick some samples from above:
"13-67(63)" --> 13,67,-1,-1,63,-1
"120(52,56)-27" --> 120,27,52,56,-1,-1
"80-1" --> 80,1,-1,-1,-1,-1
"59(59)-60(60)" --> 59,60,59,-1,60,-1
...
I can do this with combination of echo, cut, grep -o "some-regexes", .. but as I need do it for 000s of values, thats too slow, would prefer just to do in bash if possible.
https://redd.it/1kcyrna
@r_bash
I wish to do the following within bash, no external programs.
I have a shell variable which FYI contains a snooker frame score. It looks like the 20 samples below. Let's call the shell variable score. It's a scalar variable.
13-67(63) 7-68(68) 80-1 10-89(85) 0-73(73) 3-99(63) 97(52)-22 113(113)-24 59(59)-60(60) 0-67(57) 1-97(97) 120(52,56)-27 108(54)-0 130(129)-4 128(87)-0 44-71(70) 87(81)-44 72(72)-0 0-130(52,56) 90(66)-12
So we have the 2 players score separated by a "-". On each side of the - is possibly 1 or 2 numbers (separated by comma) in brackets "()". None of the numbers are more than 3 digits. (snooker fans will know anything over 147 would be unusual).
From that scalar score, I want six numbers, which are:
1: player1 score
2: player2 score
3: first number is brackets for p1
4: second number in brackets for p1
5: first number is brackets for p2
6: second number in brackets for p2
If the number does not exist, set it to -1.
So to pick some samples from above:
"13-67(63)" --> 13,67,-1,-1,63,-1
"120(52,56)-27" --> 120,27,52,56,-1,-1
"80-1" --> 80,1,-1,-1,-1,-1
"59(59)-60(60)" --> 59,60,59,-1,60,-1
...
I can do this with combination of echo, cut, grep -o "some-regexes", .. but as I need do it for 000s of values, thats too slow, would prefer just to do in bash if possible.
https://redd.it/1kcyrna
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
What to teach in awk under 4 hours for Undergraduate Computer Science students?
https://redd.it/1kd2nti
@r_bash
https://redd.it/1kd2nti
@r_bash
find; not specificName AND .png
i want a random file that is not
https://redd.it/1kd730b
@r_bash
i want a random file that is not
currentPaper and is a png. thsi does not work: what wrong? selectionPaper=$(find "$selectionPath" . \( ! -name "$currentPaper" -a -name *.png \) | shuf -n 1)https://redd.it/1kd730b
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
A command in my noscript does not run.
#!/bin/bash
for i in "$@"; do
case $i in
-W | --Wallpaper )
WALLPAPER="$2"
Hyprland & # Start Hyprland.
sleep 30s && # A Time-Delay to let Hyprland initialize.
alacritty --hold -e set-wal -w "$WALLPAPER" -c -n # Set Sysytem Theme and Wallpaper (Using "swww img" and "wal -i").
shift # Past argument with no value.
;;
-wh | --wlan-home )
WNet-Config -wh # Connect to the network.
shift # Past argument with no value.
;;
-wm | --wireless-mobile )
WNet-Config -wm # Connect to mobile hot-spot.
shift # Past argument with no value.
;;
-* | --* )
echo "Unrecognized argument ( $i )."
exit 1
;;
*)
;;
esac
shift
done
# Why would the alacritty --hold -e <noscript123> not work?
# (I don't use a login manager so maybe it has something to do with the fact it does not find a graphical interface even after Hyprland has started, somebody help please).
#
#
#
#
https://redd.it/1kefknv
@r_bash
#!/bin/bash
for i in "$@"; do
case $i in
-W | --Wallpaper )
WALLPAPER="$2"
Hyprland & # Start Hyprland.
sleep 30s && # A Time-Delay to let Hyprland initialize.
alacritty --hold -e set-wal -w "$WALLPAPER" -c -n # Set Sysytem Theme and Wallpaper (Using "swww img" and "wal -i").
shift # Past argument with no value.
;;
-wh | --wlan-home )
WNet-Config -wh # Connect to the network.
shift # Past argument with no value.
;;
-wm | --wireless-mobile )
WNet-Config -wm # Connect to mobile hot-spot.
shift # Past argument with no value.
;;
-* | --* )
echo "Unrecognized argument ( $i )."
exit 1
;;
*)
;;
esac
shift
done
# Why would the alacritty --hold -e <noscript123> not work?
# (I don't use a login manager so maybe it has something to do with the fact it does not find a graphical interface even after Hyprland has started, somebody help please).
#
#
#
#
https://redd.it/1kefknv
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community