X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=brc;h=f9c039d58aac21cb069c27721c9ac1032f2ec1c5;hb=8de1e14e35d0ad62620a59f6e2ca4ba19ddcda3c;hp=17fcfd83fe36747a94cb1c60157a5942140f74ab;hpb=ee27d59f1eea7a83b1764ec41bfb3015bb463a26;p=distro-setup diff --git a/brc b/brc index 17fcfd8..f9c039d 100644 --- a/brc +++ b/brc @@ -3514,6 +3514,34 @@ v() { fi } +# Combine files $@ into a single file with comments between them which +# allow splitting them back with fsplit. +# +# Assumes file names do not have newlines in them. +fcomb() { + local f comment out + # generated with cat /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c8 + comment='# jvvuyUsq ' + out=~/fcomb + rm -f $out + for f; do + echo "$comment$f" >>$out + cat "$f" >>$out + done +} +fsplit() { + local f fin line fin_lines + fin=~/fcomb + line=1 + fin_lines=$(wc -l "$fin" | awk '{print $1}') + comment='# jvvuyUsq ' + while (( line <= fin_lines )); do + f=$(sed -n "${line}s/^$comment//p" "$fin") + sed -n "$line,/^$comment/{/^$comment/d;p}" "$fin" >"$f" + line=$(( line + 1 + $(wc -l "$f" | awk '{print $1}') )) + done +} + # * stuff that makes sense to be at the end