Backus-Naur form for bash/posix shell noscript
Does anyone have a the bash syntax described using backus-naur form?
https://redd.it/xa4bxi
@r_bash
Does anyone have a the bash syntax described using backus-naur form?
https://redd.it/xa4bxi
@r_bash
reddit
Backus-Naur form for bash/posix shell noscript
Does anyone have a the bash syntax described using backus-naur form?
Is there a bash noscript that allows you to generate a dump sql file on a postgres database?
Is there a bash noscript that allows you to generate a dump sql file on a postgres database?
I thought that every application had a way to generate dump sql files, but I don't think DBeaver allows you to do that. Is there a way to generate some dump file of a specific database, so I can compare it after running some migration noscript?
https://redd.it/xa94pt
@r_bash
Is there a bash noscript that allows you to generate a dump sql file on a postgres database?
I thought that every application had a way to generate dump sql files, but I don't think DBeaver allows you to do that. Is there a way to generate some dump file of a specific database, so I can compare it after running some migration noscript?
https://redd.it/xa94pt
@r_bash
reddit
Is there a bash noscript that allows you to generate a dump sql file...
Is there a bash noscript that allows you to generate a dump sql file on a postgres database? I thought that every application had a way to generate...
Reliably get command denoscription offline, like tldr but offline
For historical reasons there are numerous ways to acquire command denoscription. During the time things got divergent and now we have several way to do it:
But also, there are some commands that execute regardless of arguments passed to it. It is hard to explain to beginner how to do this, without him rolling his eyes on me. So, is there any initiative/project which resolve this?
https://redd.it/xa4n3o
@r_bash
For historical reasons there are numerous ways to acquire command denoscription. During the time things got divergent and now we have several way to do it:
man, info, --help, -help, -h, -? ...continue the array. But also, there are some commands that execute regardless of arguments passed to it. It is hard to explain to beginner how to do this, without him rolling his eyes on me. So, is there any initiative/project which resolve this?
https://redd.it/xa4n3o
@r_bash
reddit
Reliably get command denoscription offline, like tldr but offline
For historical reasons there are numerous ways to acquire command denoscription. During the time things got divergent and now we have several way to...
dotfiles and root
Hi guys, I'm doing a noscript to install my dotfiles, the problem is when I want to link my files of 11X I execute my noscript with sudo but when I see my files are linked from the root directory like this /etc/X11/xorg.conf.d/20-intel.conf' -> '/root/dotfiles/X11/xorg.conf.d/20-intel.conf. I don't understand why it happened because when I run that command since the terminal that doesn't happen. How can I resolve it?
this is the line inside of my noscript: ln -sf $HOME/dotfiles/x11/ /etc/x11/
https://redd.it/x9snqf
@r_bash
Hi guys, I'm doing a noscript to install my dotfiles, the problem is when I want to link my files of 11X I execute my noscript with sudo but when I see my files are linked from the root directory like this /etc/X11/xorg.conf.d/20-intel.conf' -> '/root/dotfiles/X11/xorg.conf.d/20-intel.conf. I don't understand why it happened because when I run that command since the terminal that doesn't happen. How can I resolve it?
this is the line inside of my noscript: ln -sf $HOME/dotfiles/x11/ /etc/x11/
https://redd.it/x9snqf
@r_bash
reddit
dotfiles and root
Hi guys, I'm doing a noscript to install my dotfiles, the problem is when I want to link my files of 11X I execute my noscript with sudo but when I...
Bash if condition not working
Hey there this is my first bash noscript and the problem is with the if statement, i ask when brightness is equal to 937 (which it 100% is, i echoed the brightness before the if statement) set it to 10. However when i execute the noscript it tells me the newbrightness = 9.
What am i doing wrong?
#!/bin/sh
path=/sys/class/backlight/intel_backlight
brightness=$(cat $path/brightness)
if [$brightness == 937]; then
newbrightness=10
else
newbrightness=$(($brightness/94))
fi
echo "BRIGHTNESS: $newbrightness"
Thanks in advance!
https://redd.it/x979s7
@r_bash
Hey there this is my first bash noscript and the problem is with the if statement, i ask when brightness is equal to 937 (which it 100% is, i echoed the brightness before the if statement) set it to 10. However when i execute the noscript it tells me the newbrightness = 9.
What am i doing wrong?
#!/bin/sh
path=/sys/class/backlight/intel_backlight
brightness=$(cat $path/brightness)
if [$brightness == 937]; then
newbrightness=10
else
newbrightness=$(($brightness/94))
fi
echo "BRIGHTNESS: $newbrightness"
Thanks in advance!
https://redd.it/x979s7
@r_bash
reddit
Bash if condition not working
Hey there this is my first bash noscript and the problem is with the if statement, i ask when brightness is equal to 937 (which it 100% is, i echoed...
How to automate SSH Keygen and SSH-copy-ID to another machine automatically?
Hello. I am looking to automate a Terraform environment with Ansible, so that I can run a playbook from "terraform apply". I am using AWS and have been attempting to run a bash noscript in "user-data" so I can achieve this. I have hit a road block after many attempts, and am looking for any help. I am using ami CentOS 7 for these nodes.
In any case, to do this I need the Master Node to have SSH Key and an establish fingerprint connection with the Slave nodes. I am trying to run this in "user-data" as I am using AWS. Having a difficult time figuring this out. I know that this may be a "bad idea", especially when it comes to security of the private key. I understand that, and this is done on a test environment. This is more for learning and how these tools work together, and can always improve security methods once I see it working. Any help would be appreciated on completing the following task via Bash
\- Creating a SSH Key on master node, and sharing public key to Slave nodes with automatic fingerprint approval. So that the initial connection and known host files are updated. (Ultimately to automate an Ansible playbook to run, this is a side note).
Thanks!
https://redd.it/x90rjv
@r_bash
Hello. I am looking to automate a Terraform environment with Ansible, so that I can run a playbook from "terraform apply". I am using AWS and have been attempting to run a bash noscript in "user-data" so I can achieve this. I have hit a road block after many attempts, and am looking for any help. I am using ami CentOS 7 for these nodes.
In any case, to do this I need the Master Node to have SSH Key and an establish fingerprint connection with the Slave nodes. I am trying to run this in "user-data" as I am using AWS. Having a difficult time figuring this out. I know that this may be a "bad idea", especially when it comes to security of the private key. I understand that, and this is done on a test environment. This is more for learning and how these tools work together, and can always improve security methods once I see it working. Any help would be appreciated on completing the following task via Bash
\- Creating a SSH Key on master node, and sharing public key to Slave nodes with automatic fingerprint approval. So that the initial connection and known host files are updated. (Ultimately to automate an Ansible playbook to run, this is a side note).
Thanks!
https://redd.it/x90rjv
@r_bash
reddit
How to automate SSH Keygen and SSH-copy-ID to another machine...
Hello. I am looking to automate a Terraform environment with Ansible, so that I can run a playbook from "terraform apply". I am using AWS and have...
writing bash_profile noscripts
I found a couple functions online and am trying to figure out what a couple lines are referencing so that I can write my own - for example, this is one that lists listening connections
`listening() {`
`if [ $# -eq 0 ]; then`
`sudo lsof -iTCP -sTCP:LISTEN -n -P`
`elif [ $# -eq 1 ]; then`
`sudo lsof -iTCP -sTCP:LISTEN -n -P | grep -i --color $1`
`else`
`echo "Usage: listening [pattern]"`
`fi`
`}`
this one is for listing per process stats using the process name as the expression
`topgrep() {`
`if [[ $# -ne 1 ]]; then`
`echo "Usage: topgrep <expression>"`
`else`
`top -pid \`pgrep $1\``
`fi`
`}`
The lines in question are
`$# -eq 0`
`$# -eq 1`
`$# -ne 1`
which are a reference to the input being what?
https://redd.it/xboqkq
@r_bash
I found a couple functions online and am trying to figure out what a couple lines are referencing so that I can write my own - for example, this is one that lists listening connections
`listening() {`
`if [ $# -eq 0 ]; then`
`sudo lsof -iTCP -sTCP:LISTEN -n -P`
`elif [ $# -eq 1 ]; then`
`sudo lsof -iTCP -sTCP:LISTEN -n -P | grep -i --color $1`
`else`
`echo "Usage: listening [pattern]"`
`fi`
`}`
this one is for listing per process stats using the process name as the expression
`topgrep() {`
`if [[ $# -ne 1 ]]; then`
`echo "Usage: topgrep <expression>"`
`else`
`top -pid \`pgrep $1\``
`fi`
`}`
The lines in question are
`$# -eq 0`
`$# -eq 1`
`$# -ne 1`
which are a reference to the input being what?
https://redd.it/xboqkq
@r_bash
reddit
writing bash_profile noscripts
I found a couple functions online and am trying to figure out what a couple lines are referencing so that I can write my own - for example, this...
MATLAB/Spyder style IDE which allows for viewable workspace variables/dir and mid-noscript debugging?
Hey All,
like the noscript states, I'm looking for a tool to help me noscript in bash. I'm hoping I can find something which mirrors MATLAB's IDE, where you can see directory contents on the left, a workspace of variables on the right, and a terminal at the bottom, with your noscript in the middle.
I felt having this really sped up my comfort with coding, and I'm in a new class where many folks unfamiliar with coding are doing bash for the first time, and If we had such a tool, I think it would help people a lot (including me once we get to the more complex noscripting steps).
If anyone has any pointers to something like this, please let me know!
https://redd.it/xbud28
@r_bash
Hey All,
like the noscript states, I'm looking for a tool to help me noscript in bash. I'm hoping I can find something which mirrors MATLAB's IDE, where you can see directory contents on the left, a workspace of variables on the right, and a terminal at the bottom, with your noscript in the middle.
I felt having this really sped up my comfort with coding, and I'm in a new class where many folks unfamiliar with coding are doing bash for the first time, and If we had such a tool, I think it would help people a lot (including me once we get to the more complex noscripting steps).
If anyone has any pointers to something like this, please let me know!
https://redd.it/xbud28
@r_bash
reddit
MATLAB/Spyder style IDE which allows for viewable workspace...
Hey All, like the noscript states, I'm looking for a tool to help me noscript in bash. I'm hoping I can find something which mirrors MATLAB's IDE,...
how to run a cron job every 5 seconds.
"*/5 * * * * / runs it every 5 minutes, i need to run it every 5 seconds.
https://redd.it/x8qmue
@r_bash
"*/5 * * * * / runs it every 5 minutes, i need to run it every 5 seconds.
https://redd.it/x8qmue
@r_bash
reddit
how to run a cron job every 5 seconds.
"*/5 * * * * / runs it every 5 minutes, i need to run it every 5 seconds.
1-3 vs {1..3}
I have a question about the difference between these wildcards and how they function.
When I run “touch file{1..3}” I create three files: file1 file2 file3
But when I run “touch file1-3” I create one file named “file1-3”
Running either of these wildcards with rm however does delete all relevent files.
Why does this happen? What is the difference in the way these wildcards function?
https://redd.it/x8emnf
@r_bash
I have a question about the difference between these wildcards and how they function.
When I run “touch file{1..3}” I create three files: file1 file2 file3
But when I run “touch file1-3” I create one file named “file1-3”
Running either of these wildcards with rm however does delete all relevent files.
Why does this happen? What is the difference in the way these wildcards function?
https://redd.it/x8emnf
@r_bash
reddit
[1-3] vs {1..3}
I have a question about the difference between these wildcards and how they function. When I run “touch file{1..3}” I create three files: file1...
Is there a better way to write this if statement?
Hi, I'm making a bash noscript for personal use, and I wrote this, it does work as expected but I feel it's not the proper way to do it since it has nested if. Just curious to learn the best practices.
I hope the code is clear enough, thanks in advance.
Edit: the code is to update an SQLite table, the target represents the row and the action whether it should add or subtract.
https://redd.it/xc0z3c
@r_bash
Hi, I'm making a bash noscript for personal use, and I wrote this, it does work as expected but I feel it's not the proper way to do it since it has nested if. Just curious to learn the best practices.
I hope the code is clear enough, thanks in advance.
Edit: the code is to update an SQLite table, the target represents the row and the action whether it should add or subtract.
action= #add or subtract
target= #a or b
if [[ "$action" == "add" ]]; then
if [[ "$target" == "a" ]]; then
# some code
else
# some other code
fi
else
if [[ "$target" == "a" ]]; then
# code
else
# other code
fi
fi
https://redd.it/xc0z3c
@r_bash
reddit
Is there a better way to write this if statement?
Hi, I'm making a bash noscript for personal use, and I wrote this, it does work as expected but I feel it's not the proper way to do it since it has...
Linux/Bash/Software Help
For some reason I can't run Linux/bash commands, I downloaded Linux, I have powershell, I also got Ubuntu, allowed my computer to for the creator mode. I ran a code that tells me if I'm running bash and I'm not. The point is I scoured the internet and nothing worked, I'm drawing to the conclusion that I may have a virus and contemplating if I should have a specialist check it out. Any advice helps.
P.S I also thought about wiping my hardrive, besides my files and reinstall any needed programs.
https://redd.it/xc22sz
@r_bash
For some reason I can't run Linux/bash commands, I downloaded Linux, I have powershell, I also got Ubuntu, allowed my computer to for the creator mode. I ran a code that tells me if I'm running bash and I'm not. The point is I scoured the internet and nothing worked, I'm drawing to the conclusion that I may have a virus and contemplating if I should have a specialist check it out. Any advice helps.
P.S I also thought about wiping my hardrive, besides my files and reinstall any needed programs.
https://redd.it/xc22sz
@r_bash
reddit
Linux/Bash/Software Help
For some reason I can't run Linux/bash commands, I downloaded Linux, I have powershell, I also got Ubuntu, allowed my computer to for the creator...
gh-f stable release 1.0.0
I have worked on gh-f for about one year and I have now reached the point where I consider it to be stable and robust enough to award it a full 1.0.0 release.
## What is it?
## Is it better or worse than the others?
There are many git-fzf projects out there and they are all very good: so why should you install this other one? Because it's all-in-one place, compact, with one line installation (as
## What about this latest release?
This 1.0.0 contains no major features or improvement. Only I took the time to go through most bugfixes with many intermediate releases, often incorporating previous feedback received here on reddit/discord/GitHub and having my friends and coworkers use it for long enough to unearth major errors.
Have a look: link to the repository - there are demos, gifs and full documentation with examples. Feel free to comment, open issues and provide suggestions.
https://redd.it/x8a32w
@r_bash
I have worked on gh-f for about one year and I have now reached the point where I consider it to be stable and robust enough to award it a full 1.0.0 release.
## What is it?
gh-f is a gh CLI extension that dreams to be the ultimate fzf git integration. There are many git-fzf projects out there and we all have our own shell functions to do this and that: I wanted to unify most of it and create a one-stop shop that might address the vast majority of daily usage of git and GitHub: whilst of course it may not fulfill all needs, I found myself fulfilling most of my git needs through it.## Is it better or worse than the others?
There are many git-fzf projects out there and they are all very good: so why should you install this other one? Because it's all-in-one place, compact, with one line installation (as
gh extension) and with no need to set-up (and remember) new aliases or learn to move around some complicated TUI. It really is just git and fzf, but hopefully complete enough to replace 90% of your daily git commands. Moreover, it is easily extensible as it is just bash code that you can fork and make your own, if you want it to behave differently (no need to learn anything new if you want to make a change)## What about this latest release?
This 1.0.0 contains no major features or improvement. Only I took the time to go through most bugfixes with many intermediate releases, often incorporating previous feedback received here on reddit/discord/GitHub and having my friends and coworkers use it for long enough to unearth major errors.
Have a look: link to the repository - there are demos, gifs and full documentation with examples. Feel free to comment, open issues and provide suggestions.
https://redd.it/x8a32w
@r_bash
GitHub
GitHub - gennaro-tedesco/gh-f: 🔎 the ultimate compact fzf gh extension
🔎 the ultimate compact fzf gh extension. Contribute to gennaro-tedesco/gh-f development by creating an account on GitHub.
set -x is your friend
I enjoy looking through all the posts in this sub, to see the weird shit you guys are trying to do. Also, I think most people are happy to help, if only to flex their knowledge. However, a huge part of programming in general is learning how to troubleshoot something, not just having someone else fix it for you. One of the basic ways to do that in bash is `set -x`. Not only can this help you figure out what your noscript is doing and how it's doing it, but in the event that you need help from another person, posting the output can be beneficial to the person attempting to help.
Also, writing noscripts in an IDE that supports Bash. syntax highlighting can immediately tell you that you're doing something wrong.
If an IDE isn't an option, https://www.shellcheck.net/
https://redd.it/xcejrb
@r_bash
I enjoy looking through all the posts in this sub, to see the weird shit you guys are trying to do. Also, I think most people are happy to help, if only to flex their knowledge. However, a huge part of programming in general is learning how to troubleshoot something, not just having someone else fix it for you. One of the basic ways to do that in bash is `set -x`. Not only can this help you figure out what your noscript is doing and how it's doing it, but in the event that you need help from another person, posting the output can be beneficial to the person attempting to help.
Also, writing noscripts in an IDE that supports Bash. syntax highlighting can immediately tell you that you're doing something wrong.
If an IDE isn't an option, https://www.shellcheck.net/
https://redd.it/xcejrb
@r_bash
Linuxhint
Bash `set -x` command – Linux Hint
This tutorial is on multiple ways of enabling debugging feature for the bash noscript and the uses of the `set -x` command for debugging the bash noscript.
Having issues with editing strings
Hello, i am very new to bash noscripting and i want to remove a part of a string and save into a variable to later use in the noscript
i have a noscript that goes like this
fullString="file/filename/fizz/buzz"
cutString=${fullString} | cut -d/ -f3-
echo ${cutString}
i want to output fizz/buzz only, but i dont get anything at all
https://redd.it/xcdybx
@r_bash
Hello, i am very new to bash noscripting and i want to remove a part of a string and save into a variable to later use in the noscript
i have a noscript that goes like this
fullString="file/filename/fizz/buzz"
cutString=${fullString} | cut -d/ -f3-
echo ${cutString}
i want to output fizz/buzz only, but i dont get anything at all
https://redd.it/xcdybx
@r_bash
reddit
Having issues with editing strings
Hello, i am very new to bash noscripting and i want to remove a part of a string and save into a variable to later use in the noscript i have a...
Imagemagick annotate noscript, almost but not quite...
What I want to do..
> convert dragon.gif \
> -gravity North -background YellowGreen -splice 0x18 \
> -annotate +0+2 'Faerie Dragon' anno_splice2.gif
What I have...
>\#!/bin/bash
>echo
>echo -n "Image to use: "
>read -e infile
>echo
>echo -n "Enter text: "
>read -e text
>echo
>convert $infile -gravity North -background black -fill green -pointsize 28 -splice 0x35 -annotate +0+2 $text out.gif
Works fine with one word text but I want to enter multi word text.
Tried single and double quoting when running noscript. Nope.
Tried entering word\nword just to see what would happen, though I don't want two lines. Nope.
Tried quoting '$text' and backslashing the quotes. Nope.
*halp*
https://redd.it/xcjbie
@r_bash
What I want to do..
> convert dragon.gif \
> -gravity North -background YellowGreen -splice 0x18 \
> -annotate +0+2 'Faerie Dragon' anno_splice2.gif
What I have...
>\#!/bin/bash
>echo
>echo -n "Image to use: "
>read -e infile
>echo
>echo -n "Enter text: "
>read -e text
>echo
>convert $infile -gravity North -background black -fill green -pointsize 28 -splice 0x35 -annotate +0+2 $text out.gif
Works fine with one word text but I want to enter multi word text.
Tried single and double quoting when running noscript. Nope.
Tried entering word\nword just to see what would happen, though I don't want two lines. Nope.
Tried quoting '$text' and backslashing the quotes. Nope.
*halp*
https://redd.it/xcjbie
@r_bash
reddit
Imagemagick annotate noscript, almost but not quite...
What I want to do.. > convert dragon.gif \ > -gravity North -background YellowGreen -splice 0x18 \ > -annotate +0+2 'Faerie Dragon' ...
Can someone tell me what this command does "%00{.exec|ping -c 127.0.0.1"
https://redd.it/xckcfb
@r_bash
https://redd.it/xckcfb
@r_bash
reddit
Can someone tell me what this command does "%00{.exec|ping -c...
Posted in r/bash by u/Silent_Philosophy_86 • 1 point and 1 comment
Relative path Script and file in the same directory, trying to ma
I've got a file called 1.txt as well as a noscript in the same directory. Now, I'd like to run the noscript in order to copy 1.txt to another directory. However, I'd like to do that using a relative path.
I've tried:
... but to no avail as I'm getting the following error:
https://redd.it/x87lne
@r_bash
I've got a file called 1.txt as well as a noscript in the same directory. Now, I'd like to run the noscript in order to copy 1.txt to another directory. However, I'd like to do that using a relative path.
I've tried:
cp ./1.txt /whatever/folder ... but to no avail as I'm getting the following error:
cp: can't stat './1.txt' : No such file or directory.https://redd.it/x87lne
@r_bash
reddit
Relative path Script and file in the same directory, trying to ma
I've got a file called 1.txt as well as a noscript in the **same** directory. Now, I'd like to run the noscript in order to copy 1.txt to another...
use sed for add a txt file in another
Hello, i can't understand how to do this command.
​
I have an output file, and input file.
the output file is already write.
i need in this output file to add a new line in the top of the file, with the record inside input file.
​
i try multiple times but i can't understand how.
https://redd.it/x83ypl
@r_bash
Hello, i can't understand how to do this command.
​
I have an output file, and input file.
the output file is already write.
i need in this output file to add a new line in the top of the file, with the record inside input file.
​
i try multiple times but i can't understand how.
https://redd.it/x83ypl
@r_bash
reddit
use sed for add a txt file in another
Hello, i can't understand how to do this command. I have an output file, and input file. the output file is already write. i need in...
Changing environment variable after running a certain command.
In my bashrc I currently have this line:
export PROMPTCOMMAND="export PROMPTCOMMAND=echo"
What this does is, it will print a new line after every command EXCEPT the first one. it helps with readability and my terminal does not have an awkward space on the first line, it would look like this:
Prompt-$: Sample command
Command output
Prompt-$:
This is the expected behaviour. However, after clearing my terminal, the environment variable for PROMPT_COMMAND will still be "echo", so it will leave a gap over the prompt:
(After running clear)
(reddit won't let me add blank lines, but this line is blank in my terminal haha)
Prompt-$: Sample command
Command output
Prompt-$:
I have tried to fix it by creating a custom noscript that exports PROMPT_COMMAND to "export PROMPT_COMMAND=echo" and then runs clear. But again that is no good. Is there any way I can change it when I run ls?
https://redd.it/xcqa68
@r_bash
In my bashrc I currently have this line:
export PROMPTCOMMAND="export PROMPTCOMMAND=echo"
What this does is, it will print a new line after every command EXCEPT the first one. it helps with readability and my terminal does not have an awkward space on the first line, it would look like this:
Prompt-$: Sample command
Command output
Prompt-$:
This is the expected behaviour. However, after clearing my terminal, the environment variable for PROMPT_COMMAND will still be "echo", so it will leave a gap over the prompt:
(After running clear)
(reddit won't let me add blank lines, but this line is blank in my terminal haha)
Prompt-$: Sample command
Command output
Prompt-$:
I have tried to fix it by creating a custom noscript that exports PROMPT_COMMAND to "export PROMPT_COMMAND=echo" and then runs clear. But again that is no good. Is there any way I can change it when I run ls?
https://redd.it/xcqa68
@r_bash
reddit
Changing environment variable after running a certain command.
In my bashrc I currently have this line: export PROMPT_COMMAND="export PROMPT_COMMAND=echo" What this does is, it will print a new line...
A minimalistic bash prompt
I wrote a small bash prompt. This is based off common prompt for zsh. Let me know your thoughts.
Baksho
https://redd.it/x84wut
@r_bash
I wrote a small bash prompt. This is based off common prompt for zsh. Let me know your thoughts.
Baksho
https://redd.it/x84wut
@r_bash
GitHub
GitHub - abhi-g80/baksho: Minimalistic prompt theme for Bash
Minimalistic prompt theme for Bash. Contribute to abhi-g80/baksho development by creating an account on GitHub.