Could anyone show me how parallel works?
Does anyone have good examples of how 'parallel' can work with bash functions or noscripts? I have several for processing filetypes that I'd like to make happen more quickly
https://redd.it/1iqaw6o
@r_bash
Does anyone have good examples of how 'parallel' can work with bash functions or noscripts? I have several for processing filetypes that I'd like to make happen more quickly
https://redd.it/1iqaw6o
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Help with login noscript
I have created two login noscripts, one of which is working wonderfully. However, the other only works under certain conditions and I need some help making it more circumstance independent. Here's what I mean:
Both noscripts are for starting Google Chrome PWAs and then docking them to my system tray with kdocker. The first one is for Google Messages and the second is for Gmail.
Here is the first noscript:
#!/bin/bash
# Start Messages
/opt/google/chrome/google-chrome --profile-directory=Default --app-id=hpfldicfbfomlpcikngkocigghgafkph &
# Set ID variable
messages=$(xdotool search --sync --name "Messages - Google Messages for web")
# Pin to tray
kdocker -w $messages -i /home/ego/.local/share/icons/hicolor/128x128/apps/chrome-hpfldicfbfomlpcikngkocigghgafkph-Default.png &
# Quit
exit
And here is the second:
#!/bin/bash
# Start Gmail
/opt/google/chrome/google-chrome --profile-directory=Default --app-id=fmgjjmmmlfnkbppncabfkddbjimcfncm &
# Set ID variable
gmail=$(xdotool search --sync --name "Gmail - Inbox - myemail@gmail.com - Gmail")
# Pin to tray
kdocker -w $gmail -i /home/ego/.local/share/icons/hicolor/128x128/apps/chrome-fmgjjmmmlfnkbppncabfkddbjimcfncm-Default.png &
# Quit
exit
The problem with the Gmail noscript is that this string:
https://redd.it/1iq7bko
@r_bash
I have created two login noscripts, one of which is working wonderfully. However, the other only works under certain conditions and I need some help making it more circumstance independent. Here's what I mean:
Both noscripts are for starting Google Chrome PWAs and then docking them to my system tray with kdocker. The first one is for Google Messages and the second is for Gmail.
Here is the first noscript:
#!/bin/bash
# Start Messages
/opt/google/chrome/google-chrome --profile-directory=Default --app-id=hpfldicfbfomlpcikngkocigghgafkph &
# Set ID variable
messages=$(xdotool search --sync --name "Messages - Google Messages for web")
# Pin to tray
kdocker -w $messages -i /home/ego/.local/share/icons/hicolor/128x128/apps/chrome-hpfldicfbfomlpcikngkocigghgafkph-Default.png &
# Quit
exit
And here is the second:
#!/bin/bash
# Start Gmail
/opt/google/chrome/google-chrome --profile-directory=Default --app-id=fmgjjmmmlfnkbppncabfkddbjimcfncm &
# Set ID variable
gmail=$(xdotool search --sync --name "Gmail - Inbox - myemail@gmail.com - Gmail")
# Pin to tray
kdocker -w $gmail -i /home/ego/.local/share/icons/hicolor/128x128/apps/chrome-fmgjjmmmlfnkbppncabfkddbjimcfncm-Default.png &
# Quit
exit
The problem with the Gmail noscript is that this string:
Gmail - Inbox - myemail@gmail.com - Gmail changes based on how many emails I have in my inbox. For example, if I have three emails, it will read: Gmail - Inbox (3) - myemail@gmail.com - Gmail. This causes xdotool to not find it and subsequently causes kdocker to fail to pin it in the system tray unless I specifically have zero unread messages in my inbox, which is obviously not ideal. Can anybody help me figure out a better way to target the windows in both of my noscripts so that they are able to find the correct window in more varying conditions?https://redd.it/1iq7bko
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
printf
There are 3 places you can get info on how to use printf in bash. One is by consulting the bash man page (or help), because bash's builtin printf command is used by default. But you probably also have an installed printf command. For example, at /usr/bin/printf. So you can check
Using all of that, I came up with this printf command that I put in my PS1:
The argument to the format string (the seq) gets the current width of the terminal window, as an integer, and then spits out that many arguments, in the form of number strings. The format string produces a Unicode character and then one of the string arguments converted to zero-width. A zero-width string is literally just "". So the printf is printing the Unicode character and then nothing. But because there are, say, 100 string arguments, it'll repeat this over and over again, that many times.
The reason I came up with this is because, for a while, I was having trouble seeing where one command ran and ended when I was scrolling through my terminal window history. This printf creates a nice visual barrier that's easy to catch even when you're scrolling in the window.
Anyway, I thought it was pretty clever so I wanted to share with you guys.
https://redd.it/1iq782d
@r_bash
There are 3 places you can get info on how to use printf in bash. One is by consulting the bash man page (or help), because bash's builtin printf command is used by default. But you probably also have an installed printf command. For example, at /usr/bin/printf. So you can check
man 1 printf. There's also the printf library, which you can read about in man 3 printf. Even though bash has printf builtin, it depends on the printf library, and so some of the stuff in the two man pages applies to the builtin command as well.Using all of that, I came up with this printf command that I put in my PS1:
printf "\\u2501%.0s" $(seq "$(tput cols)")The argument to the format string (the seq) gets the current width of the terminal window, as an integer, and then spits out that many arguments, in the form of number strings. The format string produces a Unicode character and then one of the string arguments converted to zero-width. A zero-width string is literally just "". So the printf is printing the Unicode character and then nothing. But because there are, say, 100 string arguments, it'll repeat this over and over again, that many times.
The reason I came up with this is because, for a while, I was having trouble seeing where one command ran and ended when I was scrolling through my terminal window history. This printf creates a nice visual barrier that's easy to catch even when you're scrolling in the window.
Anyway, I thought it was pretty clever so I wanted to share with you guys.
https://redd.it/1iq782d
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Here're 22 best free video converter software and online apps that you can use to convert video formats without any cost.
https://www.videoproc.com/media-converter/best-video-converter.htm
https://redd.it/1iqowa9
@r_bash
https://www.videoproc.com/media-converter/best-video-converter.htm
https://redd.it/1iqowa9
@r_bash
Videoproc
9 Best Free Video Converters for PC and Mac (Compared)
Need the best video converter for Windows & Mac? This curated list covers truly free video converters and top-value paid options for all your conversion needs.
Where do you store reusable code snippets?
Hey folks! Curios where do you store your code snippets? If you work in a team how do you manage it?
https://redd.it/1iqwadh
@r_bash
Hey folks! Curios where do you store your code snippets? If you work in a team how do you manage it?
https://redd.it/1iqwadh
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Bash noscript explain
This is a noscript in Openwrt. I know what this noscript does at higher level but can I get explanation of every line.
case $PATH in
(*[!:]:) PATH="$PATH:" ;;
esac
for ELEMENT in $(echo $PATH | tr ":" "\n"); do
PATH=$ELEMENT command -v "$@"
done
https://redd.it/1iqrfzb
@r_bash
This is a noscript in Openwrt. I know what this noscript does at higher level but can I get explanation of every line.
case $PATH in
(*[!:]:) PATH="$PATH:" ;;
esac
for ELEMENT in $(echo $PATH | tr ":" "\n"); do
PATH=$ELEMENT command -v "$@"
done
https://redd.it/1iqrfzb
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Can someone explain the following: mkdir ${1:-aa}
Trying to understand the following:
mkdir ${1:-aa) and it seems to work by changing 1 to another number it works as well.
also
mkdir ${a:-a} creates a directory 1
but
mkdir ${b:-b} creates b
Any help would be great as learning.
https://redd.it/1iso5zj
@r_bash
Trying to understand the following:
mkdir ${1:-aa) and it seems to work by changing 1 to another number it works as well.
also
mkdir ${a:-a} creates a directory 1
but
mkdir ${b:-b} creates b
Any help would be great as learning.
https://redd.it/1iso5zj
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Efficient way to find outliers?
***Sorry if this is the wrong place, I use bash for most of my quick filtering, and use Julia for plotting and the more complex tasks.***
I'm trying to clean up my data to remove obvious erroneous data. As of right now, I'm implementing the following:
awk -F "\"*,\"*" 'NR>1 && $4 >= 2.5 {print $4, $6, $1}' *
And my output would look something like this, often with 100's to 1000's of lines that I look through for both a value and decimal year that I think match with my outlier. lol:
2.6157 WRHS 2004.4162
3.2888 WRHS 2004.4189
2.9593 WRHS 2004.4216
2.5311 WRHS 2004.4682
2.5541 WRHS 2004.5421
2.9214 WRHS 2004.5667
2.8221 WRHS 2004.5695
2.5055 WRHS 2004.5941
2.6548 WRHS 2004.6735
2.8185 WRHS 2004.6817
2.5293 WRHS 2004.6899
2.9378 WRHS 2004.794
2.8769 WRHS 2004.8022
2.7513 WRHS 2004.9008
2.5375 WRHS 2004.9144
2.8129 WRHS 2004.9802
Where I just make sure I'm in the correct directory depending on which component I'm looking through. I adjust the values to some value that I think represents an outlier value, along with the GPS station name and the decimal year that value corresponds to.
[Timeseries Plot](https://imgur.com/a/3p4LIqa)
Right now, I'm trying to find the three outlying peaks in the vertical component. I need to update the noscript to reflect that the lines shown are a 365-day windowed average.
I do have individual timeseries plots too, but, looking through all 423 plots is inefficient and I don't always pick out the correct one.
I guess I'm a little stuck with figuring out a solid tactic to find these outliers. I tried plotting all the station names in various arrangements, but for obvious reasons that didn't work.
Actually, now that I write this out, I could just create separate plots for the average of each station and that would quickly show me which ones are plotting as outliers -- as long as I plot the station name in the noscript...
okay, I'm going to do that. Writing this out helped. If anyone has any other idea though of how I could efficiently do this in bash, I'm always looking for efficient ways to look through my data.
:)
https://redd.it/1isop2r
@r_bash
***Sorry if this is the wrong place, I use bash for most of my quick filtering, and use Julia for plotting and the more complex tasks.***
I'm trying to clean up my data to remove obvious erroneous data. As of right now, I'm implementing the following:
awk -F "\"*,\"*" 'NR>1 && $4 >= 2.5 {print $4, $6, $1}' *
And my output would look something like this, often with 100's to 1000's of lines that I look through for both a value and decimal year that I think match with my outlier. lol:
2.6157 WRHS 2004.4162
3.2888 WRHS 2004.4189
2.9593 WRHS 2004.4216
2.5311 WRHS 2004.4682
2.5541 WRHS 2004.5421
2.9214 WRHS 2004.5667
2.8221 WRHS 2004.5695
2.5055 WRHS 2004.5941
2.6548 WRHS 2004.6735
2.8185 WRHS 2004.6817
2.5293 WRHS 2004.6899
2.9378 WRHS 2004.794
2.8769 WRHS 2004.8022
2.7513 WRHS 2004.9008
2.5375 WRHS 2004.9144
2.8129 WRHS 2004.9802
Where I just make sure I'm in the correct directory depending on which component I'm looking through. I adjust the values to some value that I think represents an outlier value, along with the GPS station name and the decimal year that value corresponds to.
[Timeseries Plot](https://imgur.com/a/3p4LIqa)
Right now, I'm trying to find the three outlying peaks in the vertical component. I need to update the noscript to reflect that the lines shown are a 365-day windowed average.
I do have individual timeseries plots too, but, looking through all 423 plots is inefficient and I don't always pick out the correct one.
I guess I'm a little stuck with figuring out a solid tactic to find these outliers. I tried plotting all the station names in various arrangements, but for obvious reasons that didn't work.
Actually, now that I write this out, I could just create separate plots for the average of each station and that would quickly show me which ones are plotting as outliers -- as long as I plot the station name in the noscript...
okay, I'm going to do that. Writing this out helped. If anyone has any other idea though of how I could efficiently do this in bash, I'm always looking for efficient ways to look through my data.
:)
https://redd.it/1isop2r
@r_bash
Imgur
Discover the magic of the internet at Imgur, a community powered entertainment destination. Lift your spirits with funny jokes, trending memes, entertaining gifs, inspiring stories, viral videos, and so much more from users.
Protect exclamation point when using double quotes and sed
Hi!
The following line
sed "/$PATTERN1/,/$PATTERN2/{/$PATTERN1/n;/$PATTERN2/!d;}" $FILE
deletes everything between the two patterns but not the lines containg them. I want to abstract this to a function. However, even when issuing the command interactively, the above line always result in this error:
Is there a way of protecting the exclamation point inside the sed command line when using double-quotes so it doesn't try to do history expansion?
Thanks!
https://redd.it/1itm6nk
@r_bash
Hi!
The following line
sed "/$PATTERN1/,/$PATTERN2/{/$PATTERN1/n;/$PATTERN2/!d;}" $FILE
deletes everything between the two patterns but not the lines containg them. I want to abstract this to a function. However, even when issuing the command interactively, the above line always result in this error:
bash: !d}: event not foundz. This makes sense because ! is history expansion. If I use the line with single quotes, there's n problem but I cannot expand the value of shell variables, which is what I want. I also tried escaping the exclamation sign, i.e. \!, but I excpetedly get unknown command:'`.Is there a way of protecting the exclamation point inside the sed command line when using double-quotes so it doesn't try to do history expansion?
Thanks!
https://redd.it/1itm6nk
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
🎉 FuzPad 2.0 is now released 🎉 FuzPad is a minimalistic note management solution. Powered by fzf
https://github.com/JianZcar/FuzPad
https://redd.it/1ito7d2
@r_bash
https://github.com/JianZcar/FuzPad
https://redd.it/1ito7d2
@r_bash
GitHub
GitHub - JianZcar/FuzPad at terminaltrove
A minimalistic note management solution. Powered by fzf - GitHub - JianZcar/FuzPad at terminaltrove
Instructions on how to grab multiple downloads using loop
I am downloading many hundreds of military documents on their use of aerosol atmospheric injection for weather control and operational strategies. One example is here:
https://babel.hathitrust.org/cgi/imgsrv/image?id=uc1.d0008795742&attachment=1&tracker=D4&format=image%2Fjpeg&size=ppi%3A300&seq=1
This is just a scanned book which is unclassified. I already have a PDF version of the book taken directly from gpo.gov and govinfo.gov but I want to save this scanned original. This link connects to a JPG scan, and the seq variable is the page number.
I want to use wget or curl or any other useful tool to pass a loop of the URL and grab all of the pages at one time.
Here is the conceptual idea:
FOR %COUNT in (1,1,52) do (
WGET "https://babel.hathitrust.org/cgi/imgsrv/image?id=uc1.d0008795742&attachment=1&tracker=D4&format=image%2Fjpeg&size=ppi%3A300&seq=%COUNT"
)
If you can help with this, it would be much appreciated. Thank you
Linux Mint 21.1 Cinnamon
Bash 5.1.16
https://redd.it/1itm3ss
@r_bash
I am downloading many hundreds of military documents on their use of aerosol atmospheric injection for weather control and operational strategies. One example is here:
https://babel.hathitrust.org/cgi/imgsrv/image?id=uc1.d0008795742&attachment=1&tracker=D4&format=image%2Fjpeg&size=ppi%3A300&seq=1
This is just a scanned book which is unclassified. I already have a PDF version of the book taken directly from gpo.gov and govinfo.gov but I want to save this scanned original. This link connects to a JPG scan, and the seq variable is the page number.
I want to use wget or curl or any other useful tool to pass a loop of the URL and grab all of the pages at one time.
Here is the conceptual idea:
FOR %COUNT in (1,1,52) do (
WGET "https://babel.hathitrust.org/cgi/imgsrv/image?id=uc1.d0008795742&attachment=1&tracker=D4&format=image%2Fjpeg&size=ppi%3A300&seq=%COUNT"
)
If you can help with this, it would be much appreciated. Thank you
Linux Mint 21.1 Cinnamon
Bash 5.1.16
https://redd.it/1itm3ss
@r_bash
can someone explain /bin/bash -c
The following 2 commands yield nothing or limited subset
sudo -u testuser echo $PATH <---I realize there is an option in visudo to preserve
sudo -u testuser env < --- this gives a much smaller/truncated output
Whereas the commands below give a the same output as if I'm logged in as the testuser
sudo -i -u testuser /bin/bash -c 'echo $PATH' <---this gets passed through regardless of option in visudo
sudo -i -u testuer /bin/bash -c 'env'
I have a guess as to what is going on but I am not 100% sure
https://redd.it/1itsp9k
@r_bash
The following 2 commands yield nothing or limited subset
sudo -u testuser echo $PATH <---I realize there is an option in visudo to preserve
sudo -u testuser env < --- this gives a much smaller/truncated output
Whereas the commands below give a the same output as if I'm logged in as the testuser
sudo -i -u testuser /bin/bash -c 'echo $PATH' <---this gets passed through regardless of option in visudo
sudo -i -u testuer /bin/bash -c 'env'
I have a guess as to what is going on but I am not 100% sure
https://redd.it/1itsp9k
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Remove whitespaces from text but only IN words. Is it even possible ?
Hello,
I have a larger textfile in german, that looks like this:
Hello this is an i n t e r e s t i n g text but i dont l i k e whitespaces.
In some random words there is also a whitespace between every character. My only idea is to create an large txt file with all german words in t h i s way and replace them if they happen. Does someone know a more elegant way ?
https://redd.it/1iu6xr4
@r_bash
Hello,
I have a larger textfile in german, that looks like this:
Hello this is an i n t e r e s t i n g text but i dont l i k e whitespaces.
In some random words there is also a whitespace between every character. My only idea is to create an large txt file with all german words in t h i s way and replace them if they happen. Does someone know a more elegant way ?
https://redd.it/1iu6xr4
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
How to remove Enter key symbol?
When executing
How can I remove that "Enter key symbol" at the end?
https://redd.it/1iuoq5q
@r_bash
When executing
cat /sys/firmware/devicetree/base/model on my Raspberry Pi in order to get the model of Pi I am working with, the output looks as follows:> cat /sys/firmware/devicetree/base/model
Raspberry Pi 3 Model B Rev 1.2⏎
How can I remove that "Enter key symbol" at the end?
https://redd.it/1iuoq5q
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Can I Use the Same Ubuntu Installation for Both WSL2 and a Bootable OS on My External SSD?
I’m setting up Ubuntu on my external SSD and I want to achieve a specific workflow:
1. Boot Ubuntu directly from my SSD when I need a full Linux environment.
2. Use the same Ubuntu installation inside Windows as WSL2 (instead of having two separate installations).
3. Keep all my files, user settings, and configurations the same between WSL2 and the bootable OS.
I tried looking into WSL2 VHDX files, but they seem to work as a virtual disk rather than a direct partition mount. Ideally, I’d like to install Ubuntu as a normal OS on my SSD, and then make Windows mount the same filesystem inside WSL2.
Has anyone done this before? Any issues with permissions, GRUB, or performance? Would love to hear your suggestions!
# System Details:
External SSD: 1TB
Planned Ubuntu Partition: 100-150GB (EXT4)
Windows Version: Windows 11
WSL Version: WSL2
Let me know if this setup is possible or if there’s a better way! 🚀
Thanks!
https://redd.it/1iuqqnq
@r_bash
I’m setting up Ubuntu on my external SSD and I want to achieve a specific workflow:
1. Boot Ubuntu directly from my SSD when I need a full Linux environment.
2. Use the same Ubuntu installation inside Windows as WSL2 (instead of having two separate installations).
3. Keep all my files, user settings, and configurations the same between WSL2 and the bootable OS.
I tried looking into WSL2 VHDX files, but they seem to work as a virtual disk rather than a direct partition mount. Ideally, I’d like to install Ubuntu as a normal OS on my SSD, and then make Windows mount the same filesystem inside WSL2.
Has anyone done this before? Any issues with permissions, GRUB, or performance? Would love to hear your suggestions!
# System Details:
External SSD: 1TB
Planned Ubuntu Partition: 100-150GB (EXT4)
Windows Version: Windows 11
WSL Version: WSL2
Let me know if this setup is possible or if there’s a better way! 🚀
Thanks!
https://redd.it/1iuqqnq
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Efficient Execution
Is there a way to load any executable once, then use the pre-loaded binary multiple times to save time and boost efficiency in Linux?
Is there a way to do the same thing, but parallelized?
My use-case is to batch run the exact same thing, same options even, on hundreds to thousands of inputs of varying size and content- and it should be quick. Quick as possible.
https://redd.it/1iurn0j
@r_bash
Is there a way to load any executable once, then use the pre-loaded binary multiple times to save time and boost efficiency in Linux?
Is there a way to do the same thing, but parallelized?
My use-case is to batch run the exact same thing, same options even, on hundreds to thousands of inputs of varying size and content- and it should be quick. Quick as possible.
https://redd.it/1iurn0j
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Name associative array after variable
I need to be able to do something like "Declare -A $var", $var"${key}"="${value}", and echo "$var${key}". What would the correct syntax for this be?
https://redd.it/1ivlhfg
@r_bash
I need to be able to do something like "Declare -A $var", $var"${key}"="${value}", and echo "$var${key}". What would the correct syntax for this be?
https://redd.it/1ivlhfg
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
What is wrong with my command using rsync?
Hi
using rsync from home to media (a pendrive) I get an error 30
rsync: receiver mkstemp "/media/jazei/MSDB/Vim/.plugins.txt.uul3Lm" failed: Read-only file system (30)
even using dirdiff I get same error read only file system...
what should I check?
I tryed chmod 777and sudo chmod... but nothing I am shielded !
this is a micro sd memory ...
see this URL screen shot: https://imgbox.com/9olj7ivT
Thank you and regards!
https://redd.it/1ixzbe1
@r_bash
Hi
using rsync from home to media (a pendrive) I get an error 30
rsync: receiver mkstemp "/media/jazei/MSDB/Vim/.plugins.txt.uul3Lm" failed: Read-only file system (30)
even using dirdiff I get same error read only file system...
what should I check?
I tryed chmod 777and sudo chmod... but nothing I am shielded !
this is a micro sd memory ...
see this URL screen shot: https://imgbox.com/9olj7ivT
Thank you and regards!
https://redd.it/1ixzbe1
@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!
I configured my bash to simulate bottom padding so my command prompt is never on the last row
https://redd.it/1iya9vk
@r_bash
https://redd.it/1iya9vk
@r_bash
Where to put sourced functions?
What is the recommended place to put sourced functions in Bash? What if I want to share those functions with other users?
`.bashrc` is probably the most obvious place, but that doesn't seem to scale very well. Is there maybe some standardized place where I can put them?
https://redd.it/1iypvm8
@r_bash
What is the recommended place to put sourced functions in Bash? What if I want to share those functions with other users?
`.bashrc` is probably the most obvious place, but that doesn't seem to scale very well. Is there maybe some standardized place where I can put them?
https://redd.it/1iypvm8
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community