diff options
author | Yasmine Aldana <yasmine@Yasmines-MacBook-Air.local> | 2024-08-10 02:09:40 -0700 |
---|---|---|
committer | Yasmine Aldana <yasmine@Yasmines-MacBook-Air.local> | 2024-08-10 02:09:40 -0700 |
commit | fd6e4546b8af25b90124c40455ad19500ec3a709 (patch) | |
tree | ed579afac7e1320e1b0e55f7369094180f61a575 | |
parent | 1d1e425b07bbb7ae04f9c7db269c359ebcdab246 (diff) |
At a lack for disk space, I'm abusing a family member's 2017 mac.mac
-rwxr-xr-x | check.rc | 22 | ||||
-rwxr-xr-x | dedup.rc | 2 | ||||
-rwxr-xr-x | del.rc | 9 |
3 files changed, 20 insertions, 13 deletions
@@ -1,21 +1,25 @@ -#!/usr/local/plan9/bin/rc +#!/usr/bin/env rc + +fn read { + $HOME/9/plan9port-master/bin/read +} fn sum { - find . -type f | while (file = `{read}) { - if (test -f $"file ) { - sha256 $"file + find $1 -type f | while (f = `{read}) { + if (test -f $"f) { + shasum -a 256 $"f } } } +dir='b' previous = '' -sum | sed -E -e 's/(.*) = (.*)/\2 \1/' -e 's/SHA256 .//' -e 's/.$//' | sort | \ - tee sum | while (line = `{read}) { #cat sum | while (line = `{read}) { - sum = `{echo $line | sed -E -e 's/([^ ]*) (.*)/\1/'} - file = `{echo $line | sed -E -e 's/([^ ]*) (.*)/\2/'} +sum $dir | sort | tee sum | while (line = `{read}) { + sum = `{echo $line | sed -e 's/ .*//'} if (~ $sum $previous) { - echo $"file is a duplicate. + file = `{echo $line | sed -e 's/[^ ]*//'} + echo $"file } previous = $sum @@ -1,3 +1,3 @@ -#!/usr/local/plan9/bin/rc +#!/usr/bin/env rc ./check.rc | ./del.rc @@ -1,8 +1,11 @@ -#!/usr/local/plan9/bin/rc +#!/usr/bin/env rc -sed -e 's/ is a duplicate.$//' | while (file = `{read}) { +fn read { + $HOME/9/plan9port-master/bin/read +} +while (file = `{read}) { if (test -f $"file) { - echo rm $"file >> /mnt/mem/log + echo rm $"file >> log rm $"file } } |