Category: shell scripting
-
Programming and Escape Characters (PowerShell)
Having started using Perl back in 1996 and learning conventions for character escaping in like eight to twelve other languages since, I’m continually impressed by how escape characters vary by language. And in the case of PowerShell, the (`) character really pulls the majority of the weight in the language. PowerShell, coming from the Microsoft…
-
Adding Lots of Storage Pools to Libvirt
I do not enjoy having subdirectories involved for storing files in libvert. The virt-manager interface is just way too brutal about how you manually add storage pools. After much ranting, I wrote a bash script to add these directories for my VM disk images. 1 #!/bin/bash 2 3 set -e 4 #set -x 5 existing_pools=()…
-
Ubuntu 18.04 Terminal Boot
Here are a series of commands to get Ubuntu 18.04 to boot into terminal mode, with various extras on how to get an automatic menu on boot up. Skipping Graphical Boot If you want to skip the graphical login screen, hit [Shift] or [Esc] before you see the grub menu to get to the grub…
-
ZFS Rebuild Script
I’ve rebuilt my zfs modules often enough that I’ve written a script to do a clean build that should avoid old kernel modules and old libraries. #!/bin/bash sudo find /lib/modules -depth -type d -iname “spl” -exec rm -rf {} \; sudo find /lib/modules -depth -type d -iname “zfs” -exec rm -rf {} \; sudo find…
-
File System Thots
A brief experiment in calculating a histogram of file sizes: $ find -type f -size -128000c -printf “%k\n” \ | sort -n \ | perl -ne ‘BEGIN{ %h=(); } {chomp $_; $h{$_}++;} END { foreach my $k (sort {$h{$a} <=> $h{$b}} keys(%h)) { print “$k $h{$k}\n”; }}’ 137 3 145 3 121 3 129 5…
-
Updated Bash CPU Meter
In August, I did a post on a pretty simple bash cpu meter. This one is still Intel-only, but is records the range of frequencies used during a report. #!/bin/bash COLWID=17 MAXTURBO=4200 function find_lines { local i=0 local j=0 while read line; do if [[ $line =~ cpu\ MHz ]]; then cpu[i]=$j ((i++)) fi ((j++))…
-
LZOP is my friend
I’ve been doing a lot of disk cloning lately, working up instructions for duplicating a “sysprep” style Fedora image for the LANforge product. Now that live CDs tend to allow live installation of packages, I can boot one, plugin in a stick with the archive of my raw image, and install pv and lzop and…
-
Making Backups of What’s Recent
You probably don’t need to backup your whole hard drive every day. Just back up what you changed recently.
-
Deleting about 24,000 files takes about 5 minutes
$ wc -l zz*txt 24028 zz-discard-paths.txt 78968 zz-keep-paths.txt 102996 total
-
Deduplication, continued.
OK, so what started out as a bash script grew into a rather finicky Perl script. I used a bunch of parallel hashes, judging things by combinations duplicate names, identical file sizes and actually scoring the path name and taking the highest score. I ended up no using the file hashes, because I decided that…