config

OpenBSD system configuration
git clone git://jacobedwards.org/config
Log | Files | Refs | README

commit b77fa63e7bb3b920f6d1c50c5dcf59c739723e04
parent 9078f756768e04a0f379d367b5e5560ce11e47cc
Author: Jacob R. Edwards <n/a>
Date:   Sat,  3 Dec 2022 12:14:37 -0600

Add addnotin, a script to add lines to files without them

The script uses notin to decide which lines from stdin get appended
to which files.

Diffstat:
Alocal/bin/bin/addnotin | 19+++++++++++++++++++
1 file changed, 19 insertions(+), 0 deletions(-)

diff --git a/local/bin/bin/addnotin b/local/bin/bin/addnotin @@ -0,0 +1,19 @@ +#!/bin/sh +# Copyright 2022 Jacob R. Edwards +# Append input lines to the given files if they don't already contain +# them. (Files must exist already.) + +if test $# -eq 1 +then + notin "$1" >> "$1" +else + input="$(mktemp -t addifnotin-XXXXXX)" + trap 'rm -f "$input"' 0 + cat > "$input" + for file + do + notin "$file" < "$input" >> "$file" + done + rm -f "$input" + trap '' 0 +fi