Enable autostart
for running VMs
for i in $(virsh list | grep running | awk '{print $2}')
do
virsh autostart $i
done
Disable autostart
for shut-off VMs
for i in $(virsh list --all | grep 'shut off' | awk '{print $2}')
do
virsh autostart --disable $i
done
Print permissions in a way that is suitable for executing again
for i in *
do
echo chown $(stat -c%U:%G $i) $i
echo chmod $(stat -c%a $i) $i
done
Rename files to remove special characters
~~~zsh
#!/bin/zsh
for f in "$1"/**/*
do
if [ -f "$f" ]
then
dir_name=$(dirname "$f")
file_name=$(basename "$f")
name=${file_name%.*}
ext=${file_name:(-4)}
good_name=$(echo "$name" | sed -re 's/\W+/_/g' -e 's/_+/_/g')"$ext"
[[ "$file_name" == "$good_name" ]] || echo mv "$f" "$dir_name"/"$good_name"
fi
done
~~~