What boredom does to a man replicating the old TVs 'no signal' color bars in BASH
https://redd.it/1g16wrq
@r_bash
https://redd.it/1g16wrq
@r_bash
I would like to make this less stupid but have no idea of what to use to get the same result.
echo $((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))
the result is a random sequence of number of 0s and 1s
1010010101111111010010110110001011100100100010110110101001101010111001001111110010100101011100101000000011010100111000101101110001111010
https://redd.it/1g1y4i6
@r_bash
echo $((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))
the result is a random sequence of number of 0s and 1s
1010010101111111010010110110001011100100100010110110101001101010111001001111110010100101011100101000000011010100111000101101110001111010
https://redd.it/1g1y4i6
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
A bash banner
https://preview.redd.it/y17eh6ai7eud1.png?width=1142&format=png&auto=webp&s=7a7a7f394fb9996aade20227d11263ea3792e99a
Script here, minus the allergens/uv data since that requires a lot of extra infrastructure:
https://gist.github.com/robbieh/c12d355ea074a7aeef9d847d76ad69f8
This noscript is designed to be run in .bashrc so I get relevant info when I first sit down and open a terminal. After the first time it shows, new terminals will get a much more terse version so that it doesn't become annoying. That resets after an hour.
The noscript contains a way to make a header with figlet and run just about anything to the right of it. That was tricky to work out.
https://redd.it/1g2a7ja
@r_bash
https://preview.redd.it/y17eh6ai7eud1.png?width=1142&format=png&auto=webp&s=7a7a7f394fb9996aade20227d11263ea3792e99a
Script here, minus the allergens/uv data since that requires a lot of extra infrastructure:
https://gist.github.com/robbieh/c12d355ea074a7aeef9d847d76ad69f8
This noscript is designed to be run in .bashrc so I get relevant info when I first sit down and open a terminal. After the first time it shows, new terminals will get a much more terse version so that it doesn't become annoying. That resets after an hour.
The noscript contains a way to make a header with figlet and run just about anything to the right of it. That was tricky to work out.
https://redd.it/1g2a7ja
@r_bash
probably stupid mistake
i dont know why but this dont work
printf "%d" $((RANDOM & 1)){$string}; echo
when this does
printf "%d" $((RANDOM & 1)){,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,}; echo
https://redd.it/1g2j8n0
@r_bash
i dont know why but this dont work
printf "%d" $((RANDOM & 1)){$string}; echo
when this does
printf "%d" $((RANDOM & 1)){,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,}; echo
https://redd.it/1g2j8n0
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Script for creating local web env
Hi, I'm practicing creating a bash noscript to streamline setting up a local web development environment for WordPress. Anyone care to give some feedback on this noscript or some best practices in general?
https://redd.it/1g2qdqk
@r_bash
Hi, I'm practicing creating a bash noscript to streamline setting up a local web development environment for WordPress. Anyone care to give some feedback on this noscript or some best practices in general?
#!/bin/bash# Define colorsGREEN='\033[0;32m'YELLOW='\033[0;33m'RED='\033[0;31m'RESET='\033[0m'# Ask user for project nameread -p "Enter the project name: " PROJECT_NAME# Check if input is not empty and doesn't containt spacesif [[ -z "$PROJECT_NAME" || "$PROJECT_NAME" =~ [[:space:]] ]]; thenecho -e "${YELLOW}Project name cannot be empty or contain spaces.${RESET}"exit 1fi# Define variablesPROJECT_DIR="/var/www/html/$PROJECT_NAME"DB_NAME="$PROJECT_NAME"DB_USER="root"DB_PASSWORD=""DB_HOST="localhost"WP_HOME="http://$PROJECT_NAME.local"WP_SITEURL="http://$PROJECT_NAME.local/wp"APACHE_CONF="/etc/apache2/sites-available/$PROJECT_NAME.conf"ETC_HOSTS="/etc/hosts"# Check if the project directory already existsif [ -d "$PROJECT_DIR" ]; thenecho -e "${YELLOW}$PROJECT_NAME already exists. Please choose another name.${RESET}"exit 1fi# Create the directory using bedrockcomposer create-project roots/bedrock "$PROJECT_DIR"# Ensure Apache can read and write to the Bedrock directorysudo chown -R www-data:www-data "$PROJECT_DIR"sudo find "$PROJECT_DIR" -type d -exec chmod 755 {} \;sudo find "$PROJECT_DIR" -type f -exec chmod 755 {} \;# Create the databaseecho "Creating database $DB_NAME..."mysql -u root -p"$MYSQL_ROOT_PASSWORD" -e "CREATE DATABASE IF NOT EXISTS $DB_NAME;"# Create a new Apache configuration for the projectecho "Creating Apache configuration for Bedrock"sudo bash -c "cat > $APACHE_CONF <<EOL<VirtualHost *:80>ServerName "$PROJECT_NAME".localDocumentRoot "$PROJECT_DIR"/web<Directory "$PROJECT_DIR"/web>Options Indexes FollowSymLinksAllowOverride AllRequire all granted</Directory>ErrorLog /var/log/apache2/"$PROJECT_NAME"-error.logCustomLog /var/log/apache2/"$PROJECT_NAME"-access.log combined</VirtualHost>EOL"# Give www-data permissions to write to /var/log/apache2/ directorysudo usermod -a -G adm www-data# Enable the new site and required modulesecho "Enablind the new site and required Apache modules..."sudo a2ensite "$PROJECT_NAME".confsudo a2enmod rewrite# Add the project to /etc/hosts if it doesn't existecho "Adding $PROJECT_NAME.local to /etc/hosts..."if ! grep -q "$PROJECT_NAME.local" /etc/hosts; thensudo bash -c "echo '127.0.0.1 $PROJECT_NAME.local' >> /etc/hosts"fi# Reload Apache for changes to take effectsystemctl reload apache2echo -e "${GREEN}$PROJECT_NAME setup completed! You can access it at http://$PROJECT_NAME.local${RESET}"https://redd.it/1g2qdqk
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Missing Alias??
hey, need help ☹️
so about a year ago, i remember setting up an alias that would take "docker" and replace it with "DOCKER_DEFAULT_PLATFORM=linux/amd64 docker-compose build" because i was getting annoyed and it saved me a ton of time.
the problem now, is that im starting to use docker again, and i cant find that alias declared anywhere. its not in .bashrc, .zshrc, .bash_profile, .profile,
i cant find it using grep (too many files, not enough CPU)
i need help. honestly its not a huge deal just spelling it wrong and then correcting it, but i need to find out where this thing is. is there any sort of log that will show everything executed on my machine? ive already tried recording with noscript shell_activity too. no results.
https://redd.it/1g2yth1
@r_bash
hey, need help ☹️
so about a year ago, i remember setting up an alias that would take "docker" and replace it with "DOCKER_DEFAULT_PLATFORM=linux/amd64 docker-compose build" because i was getting annoyed and it saved me a ton of time.
the problem now, is that im starting to use docker again, and i cant find that alias declared anywhere. its not in .bashrc, .zshrc, .bash_profile, .profile,
i cant find it using grep (too many files, not enough CPU)
i need help. honestly its not a huge deal just spelling it wrong and then correcting it, but i need to find out where this thing is. is there any sort of log that will show everything executed on my machine? ive already tried recording with noscript shell_activity too. no results.
https://redd.it/1g2yth1
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
presenting `plock` - a *very* efficient pure-bash alternative to `flock` that implements locking
## [LINK TO CODE ON GITHUB](https://github.com/jkool702/misc-public-noscripts/blob/main/plock.bash)
plock uses shared anonymous pipes to implement locking *very* efficiently. Other than bash, its only dependencies are `find` and that you have procfs available at `/proc`
## USAGE
First source the plock function
. /path/to/plock.bash
Next, you open a file denoscriptor to a shared anonymous pipe using one of the following commands. Note: these will set 2 variables in your shell: PLOCK_ID and PLOCK_FD
plock -i # this initializes a new anonymous pipe to use and opens file denoscriptors to it
plock -p ${ID} # this joins another processes existing shared anonymous pipe (identified by $ID, the pipe's inode) and opens file denoscriptors to it
To access whatever resource is in question exclusively, you use the following. This sequence can be repeated as needed. Note: To ensure exclusive access, all processes accessing the file must use this plock method (this is also true with `flock`)
plock # get lock
# < do stuff with exclusive access >
plock -u # release lock
Finally, to close the file denoscriptor to the shared anonymous pipe, run
plock -c
See the documentation at the top of the `plock` function for alternate/long flag names and for info on some additional flags not shawn above.
## What is locking?
Running code with multiple processes can speed it up tremendously. Unfortunately, having multiple processes access/modify some file or some computer resource at the same exact moment results in bad things occuring.
This problem is often solved via "locking". prior to accessing the file/resource in question, each process must aquire a lock and then release said lock after they finished their access. This ensures only one process accesses the given file/resource at any given time. `flock` is commonly used to implement this.
## How `plock` works
`plock` re-implements locking using a shared anonymous pipe with a single byte of data (a newline) in its buffer.
* You aquire the lock by reading from the pipe (emptying its buffer and causing other processes trying to read from the pipe to get blocked until there is data).
* You release the lock by writing a single newline back into the shared anonymous pipe.
This process is very efficient, and has some nice properties, including that blocked processes will sit idle, automatically queue themselves, and will automatically unblock when they aquire the lock without needing active polling. It also makes the act of aquiring or relesing a lock almost instant - on my system it takes on average about 70 μs to aquire or release a lock.
***
Questions? Comments? Suggestions? Bug reports? Let me know!
Hope some of you find this useful!
https://redd.it/1g39i1q
@r_bash
## [LINK TO CODE ON GITHUB](https://github.com/jkool702/misc-public-noscripts/blob/main/plock.bash)
plock uses shared anonymous pipes to implement locking *very* efficiently. Other than bash, its only dependencies are `find` and that you have procfs available at `/proc`
## USAGE
First source the plock function
. /path/to/plock.bash
Next, you open a file denoscriptor to a shared anonymous pipe using one of the following commands. Note: these will set 2 variables in your shell: PLOCK_ID and PLOCK_FD
plock -i # this initializes a new anonymous pipe to use and opens file denoscriptors to it
plock -p ${ID} # this joins another processes existing shared anonymous pipe (identified by $ID, the pipe's inode) and opens file denoscriptors to it
To access whatever resource is in question exclusively, you use the following. This sequence can be repeated as needed. Note: To ensure exclusive access, all processes accessing the file must use this plock method (this is also true with `flock`)
plock # get lock
# < do stuff with exclusive access >
plock -u # release lock
Finally, to close the file denoscriptor to the shared anonymous pipe, run
plock -c
See the documentation at the top of the `plock` function for alternate/long flag names and for info on some additional flags not shawn above.
## What is locking?
Running code with multiple processes can speed it up tremendously. Unfortunately, having multiple processes access/modify some file or some computer resource at the same exact moment results in bad things occuring.
This problem is often solved via "locking". prior to accessing the file/resource in question, each process must aquire a lock and then release said lock after they finished their access. This ensures only one process accesses the given file/resource at any given time. `flock` is commonly used to implement this.
## How `plock` works
`plock` re-implements locking using a shared anonymous pipe with a single byte of data (a newline) in its buffer.
* You aquire the lock by reading from the pipe (emptying its buffer and causing other processes trying to read from the pipe to get blocked until there is data).
* You release the lock by writing a single newline back into the shared anonymous pipe.
This process is very efficient, and has some nice properties, including that blocked processes will sit idle, automatically queue themselves, and will automatically unblock when they aquire the lock without needing active polling. It also makes the act of aquiring or relesing a lock almost instant - on my system it takes on average about 70 μs to aquire or release a lock.
***
Questions? Comments? Suggestions? Bug reports? Let me know!
Hope some of you find this useful!
https://redd.it/1g39i1q
@r_bash
GitHub
misc-public-noscripts/plock.bash at main · jkool702/misc-public-noscripts
miscellanuious noscripts that I want to make publically available - jkool702/misc-public-noscripts
any help in making this animation lighter and faster but still using the tput commands to set the lines and columns is welcomed.
#!/bin/bash
LINES=$(tput lines)
COLUMNS=$(tput cols)
for (( i=0; i<$LINES; i++ ))
do
clear
for (( l=0; l<=$i; l++ ))
do
echo
done
eval printf %.1s '$((RANDOM & 1))'{1..$COLUMNS}; echo
sleep 0.01
done
https://redd.it/1g3atap
@r_bash
#!/bin/bash
LINES=$(tput lines)
COLUMNS=$(tput cols)
for (( i=0; i<$LINES; i++ ))
do
clear
for (( l=0; l<=$i; l++ ))
do
echo
done
eval printf %.1s '$((RANDOM & 1))'{1..$COLUMNS}; echo
sleep 0.01
done
https://redd.it/1g3atap
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Wildcards don't work when executing noscript as a program
Hello. I've been going mad trying to figure out exactly why my Bash noscript for batch encoding videos in FFmpeg doesn't recognize wildcards as such when I run it as a program. Filename for the noscript is "batch.sh", and I am running it in a directory where I have video files I want to re-encode. Here's what I've got for the noscript:
#!/bin/sh -efu
for i in .mkv;
do
ffmpeg \
-i "$i" \
-c:v libx265 \
-c:a copy \
-dn -attach "${i%.}.png" \
-metadata:s:t mimetype=image/png \
-metadata:s:t filename=cover.png \
"${i%.} (1).mkv"
done
When I run the noscript by itself:
batch.sh
I get these errors:
[in#0 @ 0x5aaf0d6a7700] Error opening input: No such file or directory
Error opening input file .mkv.
Error opening input files: No such file or directory
However, when I run the noscript as follows:
bash batch.sh
the wildcards are recognized, and the videos get converted as they should.
I am new to all this, and I simply fail to understand exactly what's going wrong here.
https://redd.it/1g3u9fn
@r_bash
Hello. I've been going mad trying to figure out exactly why my Bash noscript for batch encoding videos in FFmpeg doesn't recognize wildcards as such when I run it as a program. Filename for the noscript is "batch.sh", and I am running it in a directory where I have video files I want to re-encode. Here's what I've got for the noscript:
#!/bin/sh -efu
for i in .mkv;
do
ffmpeg \
-i "$i" \
-c:v libx265 \
-c:a copy \
-dn -attach "${i%.}.png" \
-metadata:s:t mimetype=image/png \
-metadata:s:t filename=cover.png \
"${i%.} (1).mkv"
done
When I run the noscript by itself:
batch.sh
I get these errors:
[in#0 @ 0x5aaf0d6a7700] Error opening input: No such file or directory
Error opening input file .mkv.
Error opening input files: No such file or directory
However, when I run the noscript as follows:
bash batch.sh
the wildcards are recognized, and the videos get converted as they should.
I am new to all this, and I simply fail to understand exactly what's going wrong here.
https://redd.it/1g3u9fn
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Navita - A new Directory Jumper Utility
https://i.redd.it/mgprurmfdxud1.gif
https://redd.it/1g47ujl
@r_bash
https://i.redd.it/mgprurmfdxud1.gif
https://redd.it/1g47ujl
@r_bash
while loop through grep matches - enters loop despite no matches?
#!/bin/bash
# create text file that does NOT contain string 'error'
echo -e "foo\nbar\nbaz" > ./OUTPUT.txt
#echo -e "foo\nerror logged\nbaz" > ./OUTPUT.txt
# while loop enters regardless?
while read -r error; do
COMPILATIONERROR=true
echo "error:$error"
done <<< "$(grep "error" OUTPUT.txt)"
if [ "$COMPILATIONERROR" = true ]; then
exit 1
fi
i'm trying to parse a text file of compilation output for specific error patterns. i've created a simplified version of the file above.
i've been using grep to check for the patterns via regex, but have removed the complexity in the example above - just a simple string match demonstrates my problem. basically it seems that grep will return one 'line' that the while loop reads through, even when grep finds no match. i want the while loop to not enter at all in that scenario.
i'm not tied to grep/this while loop method to achieve an equivalent result (echo out each match in a format of my choice, and exit 1 after if matches were found). am a bash idiot and was led down this root via google!
thanks <3
https://redd.it/1g4baiz
@r_bash
#!/bin/bash
# create text file that does NOT contain string 'error'
echo -e "foo\nbar\nbaz" > ./OUTPUT.txt
#echo -e "foo\nerror logged\nbaz" > ./OUTPUT.txt
# while loop enters regardless?
while read -r error; do
COMPILATIONERROR=true
echo "error:$error"
done <<< "$(grep "error" OUTPUT.txt)"
if [ "$COMPILATIONERROR" = true ]; then
exit 1
fi
i'm trying to parse a text file of compilation output for specific error patterns. i've created a simplified version of the file above.
i've been using grep to check for the patterns via regex, but have removed the complexity in the example above - just a simple string match demonstrates my problem. basically it seems that grep will return one 'line' that the while loop reads through, even when grep finds no match. i want the while loop to not enter at all in that scenario.
i'm not tied to grep/this while loop method to achieve an equivalent result (echo out each match in a format of my choice, and exit 1 after if matches were found). am a bash idiot and was led down this root via google!
thanks <3
https://redd.it/1g4baiz
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Still Drowning
I am the Missing Alias guy from yesterday. everytime I try to post here with the link to the old post it gets removed.
I have an alias set to change "docker" to "DOCKER_DEFAULT_PLATFORM=linux/amd64 docker-compose build" from a year ago when I was working a lot with docker.
I dont want that alias to exist anymore. but I cant find it.
Here is what i've done to find and diagnose the issue:
1. tried all terminal searches recommended by the brilliant minds of this sub (thank you all, seriously)
1a. tried every other possible search technique recommended by chatgpt (desperate, learned a lot)
2. disabled all potential 3rd party app culprits
3. booted into safe mode (this stopped the text replacement)
4. created and used a new user account on my mac (this also stopped the text replacement)
5. checked in system settings -> keyboard -> text replacement (obviously, not in there.)
6. tried using keyboard maestro (my normal text replacement strategy) to cancel it with the inverse replacement, which didn't work, because my system seems to be pasting it instead of typing the string, so KM doesn't recognize the trigger string
that tells me that the action lives somewhere in my main users home folder. What I don't understand, is why the search term "docker" or "DOCKER_DEFAULT_PLATFORM=linux/amd64 docker-compose build" return no results. I have no listed aliases other than the main two that boot with macOS (run-help=man which-command=whence)
I am beginning to think this is an issue compounded from macOS software updates since I set it up. how is it possible that there is no executable file or defined alias that returns the culprit, but the text replacement still works? I can hardly get it to work under ideal conditions!
seriously spinning my head at this one. if there are any wizards out there who can help me tackle this issue, I will be forever grateful.
https://redd.it/1g3kira
@r_bash
I am the Missing Alias guy from yesterday. everytime I try to post here with the link to the old post it gets removed.
I have an alias set to change "docker" to "DOCKER_DEFAULT_PLATFORM=linux/amd64 docker-compose build" from a year ago when I was working a lot with docker.
I dont want that alias to exist anymore. but I cant find it.
Here is what i've done to find and diagnose the issue:
1. tried all terminal searches recommended by the brilliant minds of this sub (thank you all, seriously)
1a. tried every other possible search technique recommended by chatgpt (desperate, learned a lot)
2. disabled all potential 3rd party app culprits
3. booted into safe mode (this stopped the text replacement)
4. created and used a new user account on my mac (this also stopped the text replacement)
5. checked in system settings -> keyboard -> text replacement (obviously, not in there.)
6. tried using keyboard maestro (my normal text replacement strategy) to cancel it with the inverse replacement, which didn't work, because my system seems to be pasting it instead of typing the string, so KM doesn't recognize the trigger string
that tells me that the action lives somewhere in my main users home folder. What I don't understand, is why the search term "docker" or "DOCKER_DEFAULT_PLATFORM=linux/amd64 docker-compose build" return no results. I have no listed aliases other than the main two that boot with macOS (run-help=man which-command=whence)
I am beginning to think this is an issue compounded from macOS software updates since I set it up. how is it possible that there is no executable file or defined alias that returns the culprit, but the text replacement still works? I can hardly get it to work under ideal conditions!
seriously spinning my head at this one. if there are any wizards out there who can help me tackle this issue, I will be forever grateful.
https://redd.it/1g3kira
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
help
how to decode this shell noscript and make some changes in it
gH4="Ed";kM0="xSz";c="ch";L="4";rQW="";fE1="lQ";s="
how to decode this shell noscript and make some changes in it
gH4="Ed";kM0="xSz";c="ch";L="4";rQW="";fE1="lQ";s="
'=ogIXFlckIzYIRCekEHMORiIgwWY2VmCpICcahHJVRCTkcVUyRie5YFJ3RiZkAnW4RidkIzYIRiYkcHJzRCZkcVUyRyYkcHJyMGSkICIsFmdlhCJ9gnCiISPwpFe7IyckVkI9gHV7ICfgYnI9I2OiUmI9c3OiImI9Y3OiISPxBjT7IiZlJSPjp0OiQWLgISPVtjImlmI9MGOQtjI2ISP6ljV7Iybi0DZ7ISZhJSPmV0Y7IychBnI9U0YrtjIzFmI9Y2OiISPyMGS7Iyci0jS4h0OiIHI8ByJaBzZwA1UKZkWDl0NhBDM3B1UKRTVz8WaPJTT5kUbO9WSqRXTQNVSwkka0lXVWNWOJlWS3o1aVhHUTp0cVNVS3MmewkWSDNWOQdFZENVMWRXWup1UiVVT3dFbkhmYwUTSTdFZCFFMsxEVWRmWlxmWIN1VkJUUwwGTjNDcQVWRGRkWIJ0bXZEcuNmMwpkWGpVdZ5mU6J1astmVshWTZtmSUdVR5MnVW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0RZtGZ5J1VPh1brNGbGhlSFd3aWNlU0clbBl2SRBHbk1mRzl0QJtGVqJEeKh0ZrN1RNlnSIpkUWlXSLdCIi0zc7ISUsJSPxUkZ7IiI9cVUytjI0ISPMtjIoNmI9M2Oio3U4JSPw00a7ICZFJSP0g0Z' | r";HxJ="s";Hc2="";f="as";kcE="pas";cEf="ae";d="o";V9z="6";P8c="if";U=" -d";Jc="ef";N0q="";v="b";w="e";b="v |";Tx="Eds";xZp=""
x=$(eval "$Hc2$w$c$rQW$d$s$w$b$Hc2$v$xZp$f$w$V9z$rQW$L$U$xZp")
eval "$N0q$x$Hc2$rQW"
https://redd.it/1g4txj4
@r_bash
x=$(eval "$Hc2$w$c$rQW$d$s$w$b$Hc2$v$xZp$f$w$V9z$rQW$L$U$xZp")
eval "$N0q$x$Hc2$rQW"
https://redd.it/1g4txj4
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
Remove everything before a marker and after a second marker in text files -- best approach? sed? awk?
Everything I find via google is line-oriented, but my issue is needed for the whole text file.
I have text similar to:
This
is some
text
still textmarker AThis is the text to keep
This should also be kept.
And this.
And this as well.
marker BFrom here on, it's junk.
Also junk.
A lot of junk!
with a target of
This is the text to keep
This should also be kept.
And this.
And this as well.
In other words, remove everything from file up to and including marker A (example of marker: 9), and also remove everything after and including marker B (example of marker: 10). Length and contents of the segments Before, Text and After is varying.
What's the easiest way to do this? Can I use
https://redd.it/1g6eflf
@r_bash
Everything I find via google is line-oriented, but my issue is needed for the whole text file.
I have text similar to:
This
is some
text
still textmarker AThis is the text to keep
This should also be kept.
And this.
And this as well.
marker BFrom here on, it's junk.
Also junk.
A lot of junk!
with a target of
This is the text to keep
This should also be kept.
And this.
And this as well.
In other words, remove everything from file up to and including marker A (example of marker: 9), and also remove everything after and including marker B (example of marker: 10). Length and contents of the segments Before, Text and After is varying.
What's the easiest way to do this? Can I use
awk or sed for this, despite the fact that I am looking not at lines and the positions are not fixed to specific line numbers?https://redd.it/1g6eflf
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
How can prompt messages piped/redirected to a subshell be caught and made visible in the terminal, if at all possible?
I'm experimenting with formatting the output of both built-in and custom commands by piping the output to a relevant (formatting) function, which means—understandibly—piping the output to a subshell. All messages indeed show up on the terminal except for *prompt messages* from commands that require user interaction (e.g., `apt-get`).
An attempt to pipe (or redirect) the `apt-get` output to stdout results in prompt messages becoming invisible to the user, with the cursor just blinking at the end of the "assumed" prompt message:
sudo apt-get full-upgrade 2> >(while IFS= read -r line; do
if [[ "$line" =~ "Do you want to continue?" ]]; then
echo "$line"
else
echo -e "\e[31m$line\e[0m" # Color the output in red
fi
done)
Piping works the same - only the normal messages (apparently ending with a line-feed character, or `Enter`) show up formatted, with no way to bring the *prompt messages* from the subshell (buffer?) to the main one so far.
sudo apt-get full-upgrade | log_formatter # a custom function to format the output
I know that one of the solutions might well be letting the commands like `apt-get` run in the main shell only (or with `-y` option), with no piping, output formatting, no prompts, etc. But that looks ... ~~ugly~~ patchy compared with the rest of the noscript, hence remaining my last resort only.
I've also gone to the extremes (thanks to the **A**lmighty **I**mpostor), trying to catch the *prompt messages* via the `noscript` command and the following custom `spawner.exp` file, which resides in the same directory as my noscript, to no avail yet:
#!/usr/bin/expect
log_user 0
spawn sudo apt-get full-upgrade
expect {
"Do you want to continue? [Y/n] " {
send "Y\n"
exp_continue
}
}
expect eof
Any help is highly appreciated!
https://redd.it/1g7jrho
@r_bash
I'm experimenting with formatting the output of both built-in and custom commands by piping the output to a relevant (formatting) function, which means—understandibly—piping the output to a subshell. All messages indeed show up on the terminal except for *prompt messages* from commands that require user interaction (e.g., `apt-get`).
An attempt to pipe (or redirect) the `apt-get` output to stdout results in prompt messages becoming invisible to the user, with the cursor just blinking at the end of the "assumed" prompt message:
sudo apt-get full-upgrade 2> >(while IFS= read -r line; do
if [[ "$line" =~ "Do you want to continue?" ]]; then
echo "$line"
else
echo -e "\e[31m$line\e[0m" # Color the output in red
fi
done)
Piping works the same - only the normal messages (apparently ending with a line-feed character, or `Enter`) show up formatted, with no way to bring the *prompt messages* from the subshell (buffer?) to the main one so far.
sudo apt-get full-upgrade | log_formatter # a custom function to format the output
I know that one of the solutions might well be letting the commands like `apt-get` run in the main shell only (or with `-y` option), with no piping, output formatting, no prompts, etc. But that looks ... ~~ugly~~ patchy compared with the rest of the noscript, hence remaining my last resort only.
I've also gone to the extremes (thanks to the **A**lmighty **I**mpostor), trying to catch the *prompt messages* via the `noscript` command and the following custom `spawner.exp` file, which resides in the same directory as my noscript, to no avail yet:
#!/usr/bin/expect
log_user 0
spawn sudo apt-get full-upgrade
expect {
"Do you want to continue? [Y/n] " {
send "Y\n"
exp_continue
}
}
expect eof
Any help is highly appreciated!
https://redd.it/1g7jrho
@r_bash
Reddit
From the bash community on Reddit
Explore this post and more from the bash community
random wallhaven wallpaper setting
i just needed a little way to grab a random wallpaper and be able to set it and save it if i want to as my wallpaper.
it's very simple lol, but it's what i needed.
https://github.com/getjared/bash/tree/main/wc
https://redd.it/1g7jfta
@r_bash
i just needed a little way to grab a random wallpaper and be able to set it and save it if i want to as my wallpaper.
it's very simple lol, but it's what i needed.
https://github.com/getjared/bash/tree/main/wc
https://redd.it/1g7jfta
@r_bash
GitHub
bash/wc at main · getjared/bash
all my bash stuff. Contribute to getjared/bash development by creating an account on GitHub.