From Bash to Fish?
I use the Bash for more than 20 years.
I like the Bash shell. I write noscripts with:
And this helps me to automate many things.
But looking at ble.sh (previous reddit post about ble.sh) somehow makes me cry. It looks good, but there is only one maintainer.
While Bash is great for noscripting, it seems to be outdated for interactive usage.
I looked at Fish, and I like it.
How do you feel about that? Do you use Fish? Do you use it for noscripting, too?
https://redd.it/1d53k9o
@r_bash
I use the Bash for more than 20 years.
I like the Bash shell. I write noscripts with:
trap 'echo "ERROR: A command has failed. Exiting the noscript. Line was ($0:$LINENO): $(sed -n "${LINENO}p" "$0")"; exit 3' ERR
set -Eeuo pipefail
And this helps me to automate many things.
But looking at ble.sh (previous reddit post about ble.sh) somehow makes me cry. It looks good, but there is only one maintainer.
While Bash is great for noscripting, it seems to be outdated for interactive usage.
I looked at Fish, and I like it.
How do you feel about that? Do you use Fish? Do you use it for noscripting, too?
https://redd.it/1d53k9o
@r_bash
Reddit
From the bash community on Reddit: Many open issues for ble.sh (bash line editor)
Explore this post and more from the bash community
Time
Hello, i need help when it comes to create noscript that comparise changes between actual time and last time when i runned the noscript. How can i edit prevtime variable to make this works?
curtime=$(date "+%Y-%m-%d %H:%M:%S")
prevtime=$(cat last_run_time.txt)
echo $curtime > last_run_time.txt
echo $prevtime > last_run_time_previous.txt
https://redd.it/1d5a7or
@r_bash
Hello, i need help when it comes to create noscript that comparise changes between actual time and last time when i runned the noscript. How can i edit prevtime variable to make this works?
curtime=$(date "+%Y-%m-%d %H:%M:%S")
prevtime=$(cat last_run_time.txt)
echo $curtime > last_run_time.txt
echo $prevtime > last_run_time_previous.txt
https://redd.it/1d5a7or
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
A bash random word generator with huge english dictionaries
I mostly just think of this as a toy for entertainment, I have used it some over the past couple of years. However, it does have its creative and practical uses. It was just a reaction to the fact that online, I have seen random word generators, and they didn't show me any words I was unfamiliar with.
Link to repository:
https://github.com/LEDparty/bash-rwg/tree/main
https://redd.it/1d5awsb
@r_bash
I mostly just think of this as a toy for entertainment, I have used it some over the past couple of years. However, it does have its creative and practical uses. It was just a reaction to the fact that online, I have seen random word generators, and they didn't show me any words I was unfamiliar with.
Link to repository:
https://github.com/LEDparty/bash-rwg/tree/main
https://redd.it/1d5awsb
@r_bash
GitHub
GitHub - LEDparty/bash-rwg: A random word generator for the linux command line that can generate words or names.
A random word generator for the linux command line that can generate words or names. - LEDparty/bash-rwg
Trouble passing names of files to pdftk
Hi guys I'm trying to merge some pdf files into one with pdftk. So I'm doing a basic grep and formating the output but pdftk keeps trying to open a a file that does not exists.
the noscript is
if I have a file like 'My file' pdftk will try to open My\\ but obviusly it does not exists... So any Idea of why that happens???
https://redd.it/1d5on70
@r_bash
Hi guys I'm trying to merge some pdf files into one with pdftk. So I'm doing a basic grep and formating the output but pdftk keeps trying to open a a file that does not exists.
the noscript is
pdftk $(ls | grep ".pdf$" | sed 's/ /\\ /g' | tr '\n' ' ') cat output test_new.pdfif I have a file like 'My file' pdftk will try to open My\\ but obviusly it does not exists... So any Idea of why that happens???
https://redd.it/1d5on70
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
How does mapfile differentiate between a new line and a trailling new line?
https://redd.it/1d6l013
@r_bash
https://redd.it/1d6l013
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Trying to use fim to display a jpeg ...
I've written a service file that runs at boot on an Orange Pi5 plus. Basically it checks to see if /dev/video0 is available, and when it is it calls a noscript that takes the signal from HDMI in (/dev/video0), crops it and puts it out on /dev/video1 using ffmpeg & ffplay. It all works really well, and handles the HDMI in lead being unplugged and plugged back in with no problem.
What I'm having a problem with is fim. In the terminal I can type:
fim unnoscriptd.jpg
and it puts that into the frame buffer of the console, in this case /dev/video1 so that it displays the jpeg whenever the input HDMI cable is unplugged. My problem is, when I put the same command into the service file, it exits with exit code 252 or if I put the same command into my noscript, it just doesn't work. It doesn't exit from the noscript, which is good, but it doesn't display the jpeg on the console either. I'm pretty sure its some kind of permission thing, but the .sh file has been chmod +x <filename> and I've checked the permissions with ls -l <filename> and all looks good. As I said, ffmpeg/ffplay, which are both root:root work fine. I don't get why fim doesn't just display. I've been going around in circles for a few days now!
https://redd.it/1d6prkh
@r_bash
I've written a service file that runs at boot on an Orange Pi5 plus. Basically it checks to see if /dev/video0 is available, and when it is it calls a noscript that takes the signal from HDMI in (/dev/video0), crops it and puts it out on /dev/video1 using ffmpeg & ffplay. It all works really well, and handles the HDMI in lead being unplugged and plugged back in with no problem.
What I'm having a problem with is fim. In the terminal I can type:
fim unnoscriptd.jpg
and it puts that into the frame buffer of the console, in this case /dev/video1 so that it displays the jpeg whenever the input HDMI cable is unplugged. My problem is, when I put the same command into the service file, it exits with exit code 252 or if I put the same command into my noscript, it just doesn't work. It doesn't exit from the noscript, which is good, but it doesn't display the jpeg on the console either. I'm pretty sure its some kind of permission thing, but the .sh file has been chmod +x <filename> and I've checked the permissions with ls -l <filename> and all looks good. As I said, ffmpeg/ffplay, which are both root:root work fine. I don't get why fim doesn't just display. I've been going around in circles for a few days now!
https://redd.it/1d6prkh
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Right Prompt feature
Is there a way to get the "Right-prompt" feature in bash without using the "ble.sh" framework?
https://redd.it/1d70txn
@r_bash
Is there a way to get the "Right-prompt" feature in bash without using the "ble.sh" framework?
https://redd.it/1d70txn
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Opening the terminal from tje noscript file
hi, sometimes i have ro run a command to connect to vpn and then enter the password (not sudo password)
I wanted to create a .sh file that will connect after asking for password.
if i just create the bash file with the connect command then of course no window will open, how can i change the .sh file to open a terminal and continue like the connect command was typed?
https://redd.it/1d7f38j
@r_bash
hi, sometimes i have ro run a command to connect to vpn and then enter the password (not sudo password)
I wanted to create a .sh file that will connect after asking for password.
if i just create the bash file with the connect command then of course no window will open, how can i change the .sh file to open a terminal and continue like the connect command was typed?
https://redd.it/1d7f38j
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Intern Scripting Help
Hi All,
This is my first internship and I was given an assignment that Im unsure of how to start. So my company buys a bunch of raw data that is stored in an excel sheet and they want to be able to "click a button" and its automated to create another excel sheet that only takes certain columns (ones they told me they want) from the raw data and does calculations, etc. How would you do this? I was thinking of doing a sort of database that only takes in the data they want as well as does the calculations and they would need to run a noscript which would create a new excel sheet and interact with the raw data so the queries of the database can run...Im unsure if I explained it well, but anything helps! Thank you
https://redd.it/1d818nd
@r_bash
Hi All,
This is my first internship and I was given an assignment that Im unsure of how to start. So my company buys a bunch of raw data that is stored in an excel sheet and they want to be able to "click a button" and its automated to create another excel sheet that only takes certain columns (ones they told me they want) from the raw data and does calculations, etc. How would you do this? I was thinking of doing a sort of database that only takes in the data they want as well as does the calculations and they would need to run a noscript which would create a new excel sheet and interact with the raw data so the queries of the database can run...Im unsure if I explained it well, but anything helps! Thank you
https://redd.it/1d818nd
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
help with noscript
Hi everyone, I'm making a noscript that displays a "formatted" markdown file in the terminal, at first it didn't seem like much of a challenge, I managed to make the noscripts of markdown lvl1 have the background color highlighted and the following ones have the main color highlighted and bold, so, in addition to a "header" containing a markdown icon followed by the path of the displayed file, and a "show less" icon in the summary of a collapsible section, which is HTML instead of markdown (this part still doesn't work the way I want it to, but that's okay), I also managed to make the lists look nice (although I still need to hide the character that makes the list item recognizable), but the big problem I had was when I tried to work with the hyperlinks.
My goal is to display only the noscript of the hyperlink and hide the url, like "[Google\]" instead of "[Google\](https://google.com)" and make it bold, clickable, and maybe with a highlighted color using an ansi escape sequence, but after a few days of trying this seems a bit out of my league..
During my tests, the scrip did everything (underline the whole line as if it were a hyperlink, if the line had only hyperlinks, give them all the same url, or if the line had ordinary text and hyperlinks display them as [noscript\](url) instead of just [noscript\] and without being in bold) except what I wanted it to do, I don't think it leads anywhere to show the codes I tried to write, since I must have been on a completely wrong track, does anyone have any idea how this could be done?
https://redd.it/1d8arfv
@r_bash
Hi everyone, I'm making a noscript that displays a "formatted" markdown file in the terminal, at first it didn't seem like much of a challenge, I managed to make the noscripts of markdown lvl1 have the background color highlighted and the following ones have the main color highlighted and bold, so, in addition to a "header" containing a markdown icon followed by the path of the displayed file, and a "show less" icon in the summary of a collapsible section, which is HTML instead of markdown (this part still doesn't work the way I want it to, but that's okay), I also managed to make the lists look nice (although I still need to hide the character that makes the list item recognizable), but the big problem I had was when I tried to work with the hyperlinks.
My goal is to display only the noscript of the hyperlink and hide the url, like "[Google\]" instead of "[Google\](https://google.com)" and make it bold, clickable, and maybe with a highlighted color using an ansi escape sequence, but after a few days of trying this seems a bit out of my league..
During my tests, the scrip did everything (underline the whole line as if it were a hyperlink, if the line had only hyperlinks, give them all the same url, or if the line had ordinary text and hyperlinks display them as [noscript\](url) instead of just [noscript\] and without being in bold) except what I wanted it to do, I don't think it leads anywhere to show the codes I tried to write, since I must have been on a completely wrong track, does anyone have any idea how this could be done?
https://redd.it/1d8arfv
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
what is the difference between ctrl z and ctrl c?
quick question
what is the difference between ctrl z and ctrl c?
they seem to do the exact same thing as far as i can tell, is there a difference between the two?
thank you
https://redd.it/1d8lko2
@r_bash
quick question
what is the difference between ctrl z and ctrl c?
they seem to do the exact same thing as far as i can tell, is there a difference between the two?
thank you
https://redd.it/1d8lko2
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
When opening a new terminal instance with bash and running a noscript from there, how to enable user input?
Using dolphin's actions, I wanted to add a .desktop entry that:
launches a new instance of bash terminal
runs a utility console program (filetags)
which in turn expects user input to function properly
then exits
I can already achieve these steps manually - I can open a terminal myself, enter
The problem lies in the fact that with this noscript I am opening a terminal instance automatically.
This is the part which executes the terminal:
Exec=cool-retro-term -e /bin/bash -ci "source $HOME/.bashprofile && source $HOME/.bashrc && $HOME/miniconda3/bin/conda run -n base filetags '%f'"
I thought I enabled user input with `stdin` by adding the `i` parameter to `bin/bash`, but I was disappointed to learn that the program exists immediately.
Even if I add `read` or `$SHELL` or `/bin/bash` at the end of the noscript, it doesn't help. The execution has already moved past filetags. Whatever I enter later does not get piped into filetags.
For example, if I add /bin/bash at the end of the noscript:
Exec=cool-retro-term -e /bin/bash -ci "source $HOME/.bashprofile && source $HOME/.bashrc && $HOME/miniconda3/bin/conda run -n base filetags '%f'; /bin/bash"
This is the result:
user@arch > filetags
some filetags output
waiting for input
user@arch >
As you can see, the only effect I'm getting is that my window stays open, but there's no way for me to input anything for the filetags.
https://redd.it/1d8nu0d
@r_bash
Using dolphin's actions, I wanted to add a .desktop entry that:
launches a new instance of bash terminal
runs a utility console program (filetags)
which in turn expects user input to function properly
then exits
I can already achieve these steps manually - I can open a terminal myself, enter
filetags some-file and then, through stdin, enter something, confirm and it works like a charm.The problem lies in the fact that with this noscript I am opening a terminal instance automatically.
This is the part which executes the terminal:
Exec=cool-retro-term -e /bin/bash -ci "source $HOME/.bashprofile && source $HOME/.bashrc && $HOME/miniconda3/bin/conda run -n base filetags '%f'"
I thought I enabled user input with `stdin` by adding the `i` parameter to `bin/bash`, but I was disappointed to learn that the program exists immediately.
Even if I add `read` or `$SHELL` or `/bin/bash` at the end of the noscript, it doesn't help. The execution has already moved past filetags. Whatever I enter later does not get piped into filetags.
For example, if I add /bin/bash at the end of the noscript:
Exec=cool-retro-term -e /bin/bash -ci "source $HOME/.bashprofile && source $HOME/.bashrc && $HOME/miniconda3/bin/conda run -n base filetags '%f'; /bin/bash"
This is the result:
user@arch > filetags
some filetags output
waiting for input
user@arch >
As you can see, the only effect I'm getting is that my window stays open, but there's no way for me to input anything for the filetags.
https://redd.it/1d8nu0d
@r_bash
How to print dictionary with variable?
#!/bin/bash
# dictionary
declare -A ubuntu
ubuntu"name"="ubuntu"
ubuntu"cost"="0"
ubuntu"type"="os"
ubuntu"denoscription"="opens up ubuntu"
declare -A suse
suse"name"="suse"
suse"cost"="0"
suse"type"="os"
suse"denoscription"="opens up suse"
pop=suse
# prints suse denoscription
echo ${susedenoscription}
# how to make pop into a variable
echo ${$popdenoscription}
# output should be
opens up suse
https://redd.it/1d8sci2
@r_bash
#!/bin/bash
# dictionary
declare -A ubuntu
ubuntu"name"="ubuntu"
ubuntu"cost"="0"
ubuntu"type"="os"
ubuntu"denoscription"="opens up ubuntu"
declare -A suse
suse"name"="suse"
suse"cost"="0"
suse"type"="os"
suse"denoscription"="opens up suse"
pop=suse
# prints suse denoscription
echo ${susedenoscription}
# how to make pop into a variable
echo ${$popdenoscription}
# output should be
opens up suse
https://redd.it/1d8sci2
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Does regex101 work with sed, awk patterns?
I see that regex101 website is pretty common for testing regular expressions. For example to match
https://redd.it/1d9ky7n
@r_bash
I see that regex101 website is pretty common for testing regular expressions. For example to match
remote `192.168.1.1` 1194 , I see a regex in python as remote \d+\.\d+\.\d+\.\d+ 1194 and is validated by the website. I have not seen d+ in linux tools regex though. I may be wrong. What would be a website to validate sed, awk patterns?https://redd.it/1d9ky7n
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Git bash compress a video
hi I have to compress a video I downloaded git bash but I don't know how to use it what should I do to compress the video with mpeg1video codec thanks in advance
https://redd.it/1da8ufb
@r_bash
hi I have to compress a video I downloaded git bash but I don't know how to use it what should I do to compress the video with mpeg1video codec thanks in advance
https://redd.it/1da8ufb
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
I made a terminal based password manager
Hey everyone!
I’m excited to share Vaulty, a lightweight, terminal-based password manager I’ve been working on. It’s open-source, secure, and super easy to use right from your terminal.
https://preview.redd.it/o08870yq265d1.png?width=2048&format=png&auto=webp&s=b346c3b8116d18357ef05fdcfcacc5c8eb3b1c18
**Why Vaulty?**
* **Simple & Secure:** Uses AES-256 encryption and a master password for protection.
* **Local Storage:** Keeps your passwords on your machine.
* **Password Generation:** Create or generate strong passwords.
* **Idle Timeout:** Auto-exits after 2 minutes of inactivity.
**How It Works:**
1. **Setup:** Create a master password on first run.
2. **Add:** Save new passwords with a website name and username.
3. **Retrieve:** Look up saved passwords by website name.
4. **Update:** Change usernames or passwords.
5. **Delete:** Remove old entries.
**Tech Stack:**
* **Bash Script**
* **OpenSSL for AES-256 Encryption**
* **Clipboard Support** (requires `pbcopy` on macOS)
**GitHub:** [Vaulty on GitHub](https://github.com/arturfriedrich/Vaulty)
I’d love to hear your feedback and suggestions. Feel free to contribute!
Thanks for checking out Vaulty!
https://redd.it/1dadcii
@r_bash
Hey everyone!
I’m excited to share Vaulty, a lightweight, terminal-based password manager I’ve been working on. It’s open-source, secure, and super easy to use right from your terminal.
https://preview.redd.it/o08870yq265d1.png?width=2048&format=png&auto=webp&s=b346c3b8116d18357ef05fdcfcacc5c8eb3b1c18
**Why Vaulty?**
* **Simple & Secure:** Uses AES-256 encryption and a master password for protection.
* **Local Storage:** Keeps your passwords on your machine.
* **Password Generation:** Create or generate strong passwords.
* **Idle Timeout:** Auto-exits after 2 minutes of inactivity.
**How It Works:**
1. **Setup:** Create a master password on first run.
2. **Add:** Save new passwords with a website name and username.
3. **Retrieve:** Look up saved passwords by website name.
4. **Update:** Change usernames or passwords.
5. **Delete:** Remove old entries.
**Tech Stack:**
* **Bash Script**
* **OpenSSL for AES-256 Encryption**
* **Clipboard Support** (requires `pbcopy` on macOS)
**GitHub:** [Vaulty on GitHub](https://github.com/arturfriedrich/Vaulty)
I’d love to hear your feedback and suggestions. Feel free to contribute!
Thanks for checking out Vaulty!
https://redd.it/1dadcii
@r_bash
Writing auto-update noscript for my VMs. Need advice
So recently, I've been trying to noscript more and get my github filled out for better job opportunities. I currently run a proxmox 8 hypervisor with several VMs. I've been working on a simple noscript to ssh in and run updates then reboot. My issue is that when I set up these VMs, I disabled the root account so that isn't an option right now. OS being used is Proxmox 8 and for the VMs it's Ubuntu server 22. I got my rsa key to login automatically on my VMs but I haven't been able to find a way to translate that into a password-less update command.
#!/bin/bash
#List of Servers
# 1:Network 2:Plex
srvlist=( "255.255.255.255" "255.255.255.255" )
#Admin login credentials
uname=<USERNAME>
pass=<PASSWORD>
#Update each server in order in srvlist
for server in ${srvlist@}; do
echo "Working on $server"
echo $pass | ssh -tt $uname@$server "sudo apt-get update && sudo unattended-upgrade && sudo reboot --now" 1> /dev/null
done
This is what I currently have written. It works, but I don't like that I have to keep login credentials in plain text. Sure, it'll be located in a read protected location only root has access to, but it still makes me feel weird to implement. My question is, how do I do this better?
https://redd.it/1dah0ux
@r_bash
So recently, I've been trying to noscript more and get my github filled out for better job opportunities. I currently run a proxmox 8 hypervisor with several VMs. I've been working on a simple noscript to ssh in and run updates then reboot. My issue is that when I set up these VMs, I disabled the root account so that isn't an option right now. OS being used is Proxmox 8 and for the VMs it's Ubuntu server 22. I got my rsa key to login automatically on my VMs but I haven't been able to find a way to translate that into a password-less update command.
#!/bin/bash
#List of Servers
# 1:Network 2:Plex
srvlist=( "255.255.255.255" "255.255.255.255" )
#Admin login credentials
uname=<USERNAME>
pass=<PASSWORD>
#Update each server in order in srvlist
for server in ${srvlist@}; do
echo "Working on $server"
echo $pass | ssh -tt $uname@$server "sudo apt-get update && sudo unattended-upgrade && sudo reboot --now" 1> /dev/null
done
This is what I currently have written. It works, but I don't like that I have to keep login credentials in plain text. Sure, it'll be located in a read protected location only root has access to, but it still makes me feel weird to implement. My question is, how do I do this better?
https://redd.it/1dah0ux
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
sed -- change line only immediately after string match?
Can I use
https://redd.it/1dag5wm
@r_bash
[foo]
value=horse
[bar]
value=horse
[baz]
value=hearse
Can I use
sed (or another command-line tool?) to change only the second (the one in section [bar]) value?https://redd.it/1dag5wm
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community