What do you call the '-' when used to specify options (like set -x)?
View Poll
https://redd.it/1amlbbo
@r_bash
View Poll
https://redd.it/1amlbbo
@r_bash
Invoke bash noscript in remote server
I'm running a noscript from my jump host to copy a noscript to client servers. From that copied noscript will run on the client server and check for a specific agent is installed or not. If not it will install through that noscript. But before installation happen I want to raise a standard change servicenow.
Standard change raising noscript also in the jumphost. That only can be run from the jumphost.
So I want to know how can we invoke standard change raising noscript with parsing some information to that from the client machine,
https://redd.it/1amqbf8
@r_bash
I'm running a noscript from my jump host to copy a noscript to client servers. From that copied noscript will run on the client server and check for a specific agent is installed or not. If not it will install through that noscript. But before installation happen I want to raise a standard change servicenow.
Standard change raising noscript also in the jumphost. That only can be run from the jumphost.
So I want to know how can we invoke standard change raising noscript with parsing some information to that from the client machine,
https://redd.it/1amqbf8
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Dynamic FFmpeg build noscript
This builds the latest stable release version series 6 of FFmpeg with additional codecs included.
This will dynamically find the latest source code for each codec and update them accordingly.
I am slowly working on a GNU version of this noscript that will allow the user to specify a GNU all build so check back over time.
As always I hope some of you guys find this useful.
Cheers
​
Lit of codecs available
GitHub Script
https://redd.it/1ao2csh
@r_bash
This builds the latest stable release version series 6 of FFmpeg with additional codecs included.
This will dynamically find the latest source code for each codec and update them accordingly.
I am slowly working on a GNU version of this noscript that will allow the user to specify a GNU all build so check back over time.
As always I hope some of you guys find this useful.
Cheers
​
Lit of codecs available
GitHub Script
https://redd.it/1ao2csh
@r_bash
Shell noscript that can add bookmarked directories and cd into them directly (+video)
Hi all. I was getting tired of writing long cd commands to get to specific directories in the terminal. I found there were some programs/tricks for this (like CDPATH) but none of them worked for me. Hence, I made a small shell noscript that can add/delete/navigate bookmarked directories. Thank you!
You can watch a 2 minute demo here: Loom video
Or view the source code here: https://github.com/TimoKats/CDBookmark/
https://redd.it/1ao5lob
@r_bash
Hi all. I was getting tired of writing long cd commands to get to specific directories in the terminal. I found there were some programs/tricks for this (like CDPATH) but none of them worked for me. Hence, I made a small shell noscript that can add/delete/navigate bookmarked directories. Thank you!
You can watch a 2 minute demo here: Loom video
Or view the source code here: https://github.com/TimoKats/CDBookmark/
https://redd.it/1ao5lob
@r_bash
Loom
Script for Bookmarking Directories in Linux
In this video, I demonstrate a noscript that allows you to bookmark directories in your file system, making it easy to navigate to them from anywhere. I show you how to add, list, delete, and go to bookmarks using the noscript. I also explain how to set up the…
GREP - Practical Guide 🚀
Last month, I discovered one of the best terminal commands. And wrote a blog about it here - https://www.priya.today/blogs/grep
Can you share some useful tips and tricks?
I would greatly appreciate your feedback.
https://redd.it/1ao6dfz
@r_bash
Last month, I discovered one of the best terminal commands. And wrote a blog about it here - https://www.priya.today/blogs/grep
Can you share some useful tips and tricks?
I would greatly appreciate your feedback.
https://redd.it/1ao6dfz
@r_bash
Priya's blog
GREP - Practical Guide 🚀
Grep is a terminal command that allows users to search for specific patterns within text files and directories.
Anyone handle piping ?
What command line can I use to read an output from piping: "cat this.txt | xargs echo" show me a string with spaces like this "123 156 856 899". But into this.txt have next line.
I need to grab one to one that elements before spaces in the next piping command line using xargs or another commmand line.
Thanks.
https://redd.it/1aob81w
@r_bash
What command line can I use to read an output from piping: "cat this.txt | xargs echo" show me a string with spaces like this "123 156 856 899". But into this.txt have next line.
I need to grab one to one that elements before spaces in the next piping command line using xargs or another commmand line.
Thanks.
https://redd.it/1aob81w
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Using SORT but ignore "the", "a" and "an"?
As the noscript says...
I have list of noscripts. I want to sort the list, but I don't want all the noscripts starting with "the" bunch together.
I read through the man page hoping to find a way to get SORT to ignore a word, but I ran dry.
Anyone have any ideas?
https://redd.it/1aod18i
@r_bash
As the noscript says...
I have list of noscripts. I want to sort the list, but I don't want all the noscripts starting with "the" bunch together.
I read through the man page hoping to find a way to get SORT to ignore a word, but I ran dry.
Anyone have any ideas?
https://redd.it/1aod18i
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Please give me pointers on how to make my watermark noscript suck less
#!/bin/bash
# First, a file to work on is picked
echo "Which file to work on?"
read -e "filetoworkon"
# Then, the format to convert to is chosen:
# 1) 13x18cm (2126px wide)
# 2) 18x13cm (942px wide)
read -n1 -p "Pick 1) for 18x13 or 2) for 13x18 1,2" doit
case $doit in
1) convert "$filetoworkon" -resize 2126 "$filetoworkon"-resized.png ;;
2) convert "$filetoworkon" -resize 492 "$filetoworkon"-resized.png ;;
) echo dont know ;;
esac
# Then the file to use as a watermark is chosen
echo "Which file to use as watermark?"
# A list of options is given
echo "Options:"
ls my-logo-.pdf
read -e "watermarkfile"
# Finally, the watermark is added
convert "$filetoworkon"-resized.png "$watermarkfile" +distort affine "0,0 0,0 %w,%h %fx:t?v.w*(u.h/v.h*0.05):s.w,%fx:t?v.h*(u.h/v.h*0.05):s.h" -shave 1 -gravity southeast -geometry +50+50 -compose hard-light -composite "$filetoworkon"-resized-signed.png
echo ""File saved as "$filetoworkon"-resized-signed.png""
It does what it has to, but it is ugly and there is some redundancy. I've also been told that I should use functions instead of
​
I hope someone will help me clean up this thing, and explain how it could be improved.
https://redd.it/1aosyju
@r_bash
#!/bin/bash
# First, a file to work on is picked
echo "Which file to work on?"
read -e "filetoworkon"
# Then, the format to convert to is chosen:
# 1) 13x18cm (2126px wide)
# 2) 18x13cm (942px wide)
read -n1 -p "Pick 1) for 18x13 or 2) for 13x18 1,2" doit
case $doit in
1) convert "$filetoworkon" -resize 2126 "$filetoworkon"-resized.png ;;
2) convert "$filetoworkon" -resize 492 "$filetoworkon"-resized.png ;;
) echo dont know ;;
esac
# Then the file to use as a watermark is chosen
echo "Which file to use as watermark?"
# A list of options is given
echo "Options:"
ls my-logo-.pdf
read -e "watermarkfile"
# Finally, the watermark is added
convert "$filetoworkon"-resized.png "$watermarkfile" +distort affine "0,0 0,0 %w,%h %fx:t?v.w*(u.h/v.h*0.05):s.w,%fx:t?v.h*(u.h/v.h*0.05):s.h" -shave 1 -gravity southeast -geometry +50+50 -compose hard-light -composite "$filetoworkon"-resized-signed.png
echo ""File saved as "$filetoworkon"-resized-signed.png""
It does what it has to, but it is ugly and there is some redundancy. I've also been told that I should use functions instead of
read -e, but I don't know how. ​
I hope someone will help me clean up this thing, and explain how it could be improved.
https://redd.it/1aosyju
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Move to new $ line
I need to move to a directory, move to a new line and execute a noscript.
user@ubuntu:\~$ mynoscript
user@ubuntu:\~/Documents$ server started on port 3000
Right now my noscript executes like this
user@ubuntu:\~$ server started on port 3000
​
https://redd.it/1aox1kr
@r_bash
I need to move to a directory, move to a new line and execute a noscript.
user@ubuntu:\~$ mynoscript
user@ubuntu:\~/Documents$ server started on port 3000
Right now my noscript executes like this
user@ubuntu:\~$ server started on port 3000
​
https://redd.it/1aox1kr
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
I can't understand the result. bad string to variable assignment.
if I run:
# as expected result:
text "https://dl.discordapp.net/apps/linux/0.0.43/discord-0.0.43.deb"
but,
or
# strange result:
"ext "https://dl.discordapp.net/apps/linux/0.0.43/discord-0.0.43.deb
the first letter of 'text' is removed: 'ext'.
the double quotes are moved to the first token instead of covering up the URL.
I don't know how to explain it, I don't know how to research it, I have no idea what the problem is or how to solve it.
thx _o/
https://redd.it/1apetnl
@r_bash
if I run:
URL=https://dl.discordapp.net/apps/linux/0.0.43/discord-0.0.43.deb; echo "text \"$URL\"";# as expected result:
text "https://dl.discordapp.net/apps/linux/0.0.43/discord-0.0.43.deb"
but,
URL=$(curl -Is -- 'https://discord.com/api/download/stable?platform=linux&format=deb' | grep -i 'location' | awk '{print $2}'); echo "text \"$URL\"";or
URL=$(curl -Is -- 'https://discord.com/api/download/stable?platform=linux&format=deb' | grep -i 'location' | cut -d' ' -f2); echo "text \"$URL\"";# strange result:
"ext "https://dl.discordapp.net/apps/linux/0.0.43/discord-0.0.43.deb
the first letter of 'text' is removed: 'ext'.
the double quotes are moved to the first token instead of covering up the URL.
I don't know how to explain it, I don't know how to research it, I have no idea what the problem is or how to solve it.
thx _o/
https://redd.it/1apetnl
@r_bash
Script acts differently when called with sh compared to bash
Weird noscript but bear with me.
​
So I have a noscript that fails on machines when called without specifying bash. The noscript ultimately does the below as an example.
​
mynoscript
#!/bin/bash
#
#
#
searchPath=/opt/folder/files/
player < ${searchPath}/music.mp3
When I call the noscript as /bin/mynoscript, i fails with "No such file or directory" and does not appear to expand the \ as a wildcard. If I call it as "bash /bin/mynoscript" it functions correctly and handles the wildcard.
​
Any thoughts on why it fails unless I specify "bash" even though there is a shebang/execute bits?
https://redd.it/1aphmz7
@r_bash
Weird noscript but bear with me.
​
So I have a noscript that fails on machines when called without specifying bash. The noscript ultimately does the below as an example.
​
mynoscript
#!/bin/bash
#
#
#
searchPath=/opt/folder/files/
player < ${searchPath}/music.mp3
When I call the noscript as /bin/mynoscript, i fails with "No such file or directory" and does not appear to expand the \ as a wildcard. If I call it as "bash /bin/mynoscript" it functions correctly and handles the wildcard.
​
Any thoughts on why it fails unless I specify "bash" even though there is a shebang/execute bits?
https://redd.it/1aphmz7
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
How to get realtime output from bash
Have a noscript that runs a custom program within bash, the exe takes a while to run, about 5 minutes, but when you run it there are heartbeats printed to let the user know that it is still running, on my bash, those messages appear after the noscript has finished running, also, it seems the buffer is full and not every message gets printed, I tried redirecting to a file but still the output is not "real time"
something like
# !/bin/bash
testexecutable --flag=1 | tee "/tmp/testoutput.txt"
this is on macos, also tried to output to /dev/tty but it says its not configured.
https://redd.it/1apk4hq
@r_bash
Have a noscript that runs a custom program within bash, the exe takes a while to run, about 5 minutes, but when you run it there are heartbeats printed to let the user know that it is still running, on my bash, those messages appear after the noscript has finished running, also, it seems the buffer is full and not every message gets printed, I tried redirecting to a file but still the output is not "real time"
something like
# !/bin/bash
testexecutable --flag=1 | tee "/tmp/testoutput.txt"
this is on macos, also tried to output to /dev/tty but it says its not configured.
https://redd.it/1apk4hq
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Why does "cat | ls" behave like that?
Hello everyone,
I am doing a project that consists on replicating bash (some of its basic behavior) in C.
I am still on the early stages of the project, analyzing how bash behaves with different inputs.
The point is that I was playing with some basic commands and its combinations through pipe (|) operator, and when I tried "cat | ls" I was kind of expecting just the ouput of ls, but instead got:
bash-4.4$ cat | ls
file1 file2 file3
And it just holds there awaiting for input. Then after just enter it stop the execution with a result of:
bash-4.4$ cat | ls
file1 file2 file3
bash-4.4$
It feel like bash its prioritizing ls over cat, does anyone know what is going on underneath?
Thanks!
https://redd.it/1apxpef
@r_bash
Hello everyone,
I am doing a project that consists on replicating bash (some of its basic behavior) in C.
I am still on the early stages of the project, analyzing how bash behaves with different inputs.
The point is that I was playing with some basic commands and its combinations through pipe (|) operator, and when I tried "cat | ls" I was kind of expecting just the ouput of ls, but instead got:
bash-4.4$ cat | ls
file1 file2 file3
And it just holds there awaiting for input. Then after just enter it stop the execution with a result of:
bash-4.4$ cat | ls
file1 file2 file3
bash-4.4$
It feel like bash its prioritizing ls over cat, does anyone know what is going on underneath?
Thanks!
https://redd.it/1apxpef
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
some help with this example noscript
So lets say I have 50 different noscripts I need to run.
For the last section that checks error codes -ne 0, is there a way
I can some how put this in some loop that checks $exitcode1-50
without having to state each variable.
-----------------------
#!/bin/bash
testnoscript1="test1.sh"
testnoscript2="test2.sh"
testnoscript3="test3.sh"
# Run the first test noscript and store the exit code
$testnoscript1
exitcode1=$?
# Run the second test noscript and store the exit code
$testnoscript2
exitcode2=$?
# Run the third test noscript and store the exit code
$testnoscript3
exitcode3=$?
# Check the exit codes and exit with error 1 if any of them is non-zero
if $exit_code_1 -ne 0 || $exit_code_2 -ne 0 || $exit_code_3 -ne 0 ; then
exit 1
fi
https://redd.it/1aqzji0
@r_bash
So lets say I have 50 different noscripts I need to run.
For the last section that checks error codes -ne 0, is there a way
I can some how put this in some loop that checks $exitcode1-50
without having to state each variable.
-----------------------
#!/bin/bash
testnoscript1="test1.sh"
testnoscript2="test2.sh"
testnoscript3="test3.sh"
# Run the first test noscript and store the exit code
$testnoscript1
exitcode1=$?
# Run the second test noscript and store the exit code
$testnoscript2
exitcode2=$?
# Run the third test noscript and store the exit code
$testnoscript3
exitcode3=$?
# Check the exit codes and exit with error 1 if any of them is non-zero
if $exit_code_1 -ne 0 || $exit_code_2 -ne 0 || $exit_code_3 -ne 0 ; then
exit 1
fi
https://redd.it/1aqzji0
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Using JQ to return the index number for every occurrence of an element in an array
Take the following example. How can I use
{
"embeds":
{
"name": "Name1"
"field": "Field1"
"field": "Field2"
}
{
"name": "Name3"
"field": "Field3"
}
{
"name": "Name1"
"field": "Field1"
"field": "Field2"
"field": "Field3"
}
}
​
https://redd.it/1ard3he
@r_bash
Take the following example. How can I use
jq to return an array of the embeds index number for each occurance of the field element in the Json? I.e. [0 0 1 2 2 2]{
"embeds":
{
"name": "Name1"
"field": "Field1"
"field": "Field2"
}
{
"name": "Name3"
"field": "Field3"
}
{
"name": "Name1"
"field": "Field1"
"field": "Field2"
"field": "Field3"
}
}
​
https://redd.it/1ard3he
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Interested in using zsh to run a program that requires bash...
I feel like this would be an easy lift for an experienced linux user but I haven't done more than a few google searches on this yet...
This app requires a settings.sh noscript sourced before you use it, so I cant just alias all the cmds with `bash -c $app`. I need the bash shell env setup by the settings.sh, then I need to be able to have zsh push all cmds starting with that apps name to the shell that has been setup.
I feel like there's got to be a way to have cmds run from zsh that open a bash shell and then specify in .zshrc (with aliases) which cmds get sent to that bash shell...
also, the only reason this particular linux box exists is to run this app, so I don't care if the solution somehow lightly interferes on other use cases...
thanks for reading.
​
https://redd.it/1ard6yd
@r_bash
I feel like this would be an easy lift for an experienced linux user but I haven't done more than a few google searches on this yet...
This app requires a settings.sh noscript sourced before you use it, so I cant just alias all the cmds with `bash -c $app`. I need the bash shell env setup by the settings.sh, then I need to be able to have zsh push all cmds starting with that apps name to the shell that has been setup.
I feel like there's got to be a way to have cmds run from zsh that open a bash shell and then specify in .zshrc (with aliases) which cmds get sent to that bash shell...
also, the only reason this particular linux box exists is to run this app, so I don't care if the solution somehow lightly interferes on other use cases...
thanks for reading.
​
https://redd.it/1ard6yd
@r_bash
Can somebody tell me if these noscripts would overwrite or just add to a file?
I have two noscripts I'd like to employ in AWS to update a file as a dynamic IP changes. I found two, but would like to know the differences in them, particularly if they add a new IP to a file and not remove the old one, or if it would overwrite the old one and not leave the ones that it detects have changed. I apologize. I have no good experience in Bash.
https://www.daniloaz.com/en/how-to-automatically-update-all-your-aws-ec2-security-groups-when-your-dynamic-ip-changes/
https://urldefense.com/v3/__https:/medium.com/@dbclin/a-bash-noscript-to-update-an-existing-aws-security-group-with-my-new-public-ip-address-d0c965d67f28__;!!KM6X6ZXWXVtZMQ!Yaqsfx8kuqjQn_wOppmhh5CGZpL8wqA6tTxE-QcD4VvFKhn6lecIlY1AHzGeQOeqVUHZhQlrzeIREUaImh4TDyYSitbYBg$
https://redd.it/1aru8uy
@r_bash
I have two noscripts I'd like to employ in AWS to update a file as a dynamic IP changes. I found two, but would like to know the differences in them, particularly if they add a new IP to a file and not remove the old one, or if it would overwrite the old one and not leave the ones that it detects have changed. I apologize. I have no good experience in Bash.
https://www.daniloaz.com/en/how-to-automatically-update-all-your-aws-ec2-security-groups-when-your-dynamic-ip-changes/
https://urldefense.com/v3/__https:/medium.com/@dbclin/a-bash-noscript-to-update-an-existing-aws-security-group-with-my-new-public-ip-address-d0c965d67f28__;!!KM6X6ZXWXVtZMQ!Yaqsfx8kuqjQn_wOppmhh5CGZpL8wqA6tTxE-QcD4VvFKhn6lecIlY1AHzGeQOeqVUHZhQlrzeIREUaImh4TDyYSitbYBg$
https://redd.it/1aru8uy
@r_bash
daniloaz.com
How to automatically update all your AWS EC2 security groups when your dynamic IP changes
One of the biggest annoyances when working with AWS and your Internet connection has a dynamic IP is that when it changes, you immediately stop accessing to all servers and services protected by an EC2 security group whose rules only allow traffic to certain…
Continuously update display while waiting for user input
I want to write a little bash noscript that continuously updates some values on the screen (in my case, packets per second), while also waiting on user input from a small menu of options presented to the user. In the year of our lord 2024, is there not a better solution than an infinite while loop and read with a 1 second timeout? Is this something dialog(1) could help me do? Thank you.
https://redd.it/1asksmi
@r_bash
I want to write a little bash noscript that continuously updates some values on the screen (in my case, packets per second), while also waiting on user input from a small menu of options presented to the user. In the year of our lord 2024, is there not a better solution than an infinite while loop and read with a 1 second timeout? Is this something dialog(1) could help me do? Thank you.
https://redd.it/1asksmi
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
I developed a program that interacts with a shell but accidentally I entered a backslash
After I entered \ the shell is stuck, expecting me to press enter. Is there any way to exit this?
As I interact via a text field I don’t know how I could simulate an enter keypress and \n does not work
https://redd.it/1askmtv
@r_bash
After I entered \ the shell is stuck, expecting me to press enter. Is there any way to exit this?
As I interact via a text field I don’t know how I could simulate an enter keypress and \n does not work
https://redd.it/1askmtv
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
hacky interactive error handler with restarts for bash
https://github.com/sczi/bash_error_handler
https://redd.it/1at12a1
@r_bash
https://github.com/sczi/bash_error_handler
https://redd.it/1at12a1
@r_bash
GitHub
GitHub - sczi/bash_error_handler: "Break on exception" for bash
"Break on exception" for bash. Contribute to sczi/bash_error_handler development by creating an account on GitHub.