In the code below we wait for a background process three times. In the first paragraph we get the expected 0 return code from the wait. In the second paragraph the only change is wrapping the wait in a command substitution which instead gives a 255 return code. In the third paragraph the only change is wrapping the wait in a subshell which gives a 127 return code. Why is this?
bash
sleep 1 &
wait $!
echo $? # prints "0"
sleep 1 &
a=$(wait $!) # <---- only difference is cmd substitution
echo $? # prints "255"
sleep 1 &
(wait $! &>/dev/null) # <---- only difference is subshell
echo $? # prints "127"
Thanks in advance for your thoughts!
EDIT: updated to include the subshell final example also, which gives a clue
The output is abc, but I can't figure out why. I understand that %d is used to indicate an integer number and * represents anything, but I can't figure out why those together would truncate var to only 3 characters.
I made grebuntu to merge all of the separate scripts into one script for all distros, but it doesn't work. The individual scripts do, I tested in VMs. What could have caused the issue? the script in question is tsubuntu.sh btw, can be found in the repo
The original scripts are available at https://github.com/Tsu-gu/tsubuntu
I'm trying to put a command together to download a bz2 archive containing an img file and decompress it immediately, basically without saving it to the filesystem. Can this be done?
Background: Trying to install OPNsense on Linode. Their hacky official guide says the best way to install FreeBSD is via the rescue mode. But FreeBSD posts their images as .img, so the filesystem size limitation of 1GB for the rescue image isn't an issue. But with OPNsense I need to decompress it.
I have a few different options on how to install this but I see it as a good reason to learn more about stdin/out, piping commands, etc.
After a long process of roaming the web, re-runs and troubleshoot the script with this wonderful community, the script is functional and does what it's intended to do. The script itself is probably even further improvable in terms of efficiency/logic, but I lack the necessary skills/knowledge to do so, feel free to copy, edit or even propose a more efficient way of doing the same thing.
I'm greatly thankful to @[email protected], @[email protected], @[email protected] and Phil Harvey (exiftool) for their help, time and all the great idea's (and spoon-feeding me with simple and comprehensive examples ! )
How to use
Prerequisites:
parallel package installed on your distribution
Copy/past the below script in a file and make it executable. Change the start_range/end_range to your needs and install the parallel package depending
I was able to setup a debugger using a launch mode using Visual Studio Code with the Bash Debug extension. Is it possible to setup the debugger in VSCode to be able to debug a bash script using a attach debug mode?
For debugging scripts on the host machine and scripts inside a docker container?
#!/usr/bin/env bash
# Download and search youtube subs
# deps yt-dlp ,awk, perl, any one or more of either ugrep, ripgrep, grep
# usage "script youtube_url"
main() {
url="$@"
check_if_url
get_video_id
search_for_downloaded_matching_files
set_download_boolean_flag
download_subs
read_and_format_transcript_file
echo_description_file
user_search
}
# Iterate over the array and add items to the new array if they match the regex
check_if_url() {
local regex='^https://[^[:space:]]+$'
if ! [[ $url =~ $regex ]]; then
echo "Invalid input. Valid input is a url matching regex ${regex}"
exit 1
fi
}
get_video_id() {
video_id=$(echo "$url" | sed -n 's/.*v=\([^&]*\).*/\1/p')
}
search_for_downloaded_matching_files() {
# Find newest created files matching the
This is all good, but I am not trying to download whole playlists and I want to make sure to
Not download any songs multiple times by comparing the files you are trying to download with the songs you have downloaded already.
Add the songs' URL to the Archieve_file so it doesn't download it again. i.e., compare and if present, exit loop, if not present in file, download and add link to the file.
This was easier when I was dealing with only song links and not playlist links. But now, playlists complicates the equation, but if I can achieve this, I can basically add this script to `c
I would rather prefer that you would buy spotify premium if you can. But, till you can, there's always spotdl which can allow you to download your songs
btw, I am using file manager nemo here, if you want something else, change it to your default file manager, if you don't want to open folder, well remove last but one line.
execute this command first and when nano text edit appears, paste the debian pastebin in there.
::: spoiler spoiler
This will remove all sponsors, download subtitles and view it when you are watching a video. Modify and Share this all over if you like!
Edit: Give credits to this community or Lemmy in general if you are posting this or a modified form (please do share) of this elsewhere. Some popularity would do Lemmy good.
Few requirements:
You should be using Linux to run it.
Create a folder named yt-dlp in Videos folder or else change the location in the script below.
You should have yt-dlp not youtube-dl on your system.
You can do this by sudo apt install yt-dlp or use your distro's package installer.
Save this file with any name in your home folder (or whichever folder you are you most comfortable with and give it execution permissions by chmod +x name
Debian Pastebin Thanks to folds at debian for making a tor network friendly pastebin. I have noticed that sometimes scripts get corrupted here, so best copy this from pastebi
The issue is that if my script is correctly done, a SVG is supposed to be exported to PNG with a fixed width, the script seems to work fine, but when I check it out again on Inkscape*, it shows me the original SVG size, not the resized PNG exported picture.
*To check the size of the picture in Inkscape, we need to change the units in the top bar, and then see the numbers that shows. The screenshot shows a 14,79 cm x 9,85 cm, instead of 10,5 cm x 6,9 cm.
Attached: 1 video
So today I sat down to practice guitar and I realized that I left both my metronomes at my sister's room. Obviously I wasn't going to get up to go and fetch one, so I picked up a bash spell tome (man SoX) and with a little bash magic, made a basic metronome.
Here is the actual co...
Link Actions
So today I sat down to practice guitar and I realized that I left both my metronomes at my sister's room. Obviously I wasn't going to get up to go and fetch one, so I picked up a bash spell tome (man SoX) and with a little bash magic, made a basic metronome.
Here is the actual code:
undefined
tempo ()
{
play -n -c1 synth 0.001 sine 1000 pad $(awk "BEGIN { print 60/$1 -.001 }") repeat 999999
}