Created
June 7, 2018 22:47
-
-
Save lutter/b28328ecc532d052c950175c120164bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Use as 'lines.sh /some/file' | |
# The file we want to manipulate | |
src=/tmp/lines.txt | |
# The line we are looking for (including quotes !) | |
line="'Include $1'" | |
# This is ugly but works with released augeas going a long way back | |
if augtool -e -At "Simplelines incl $src" "match /files/tmp/lines.txt/*[. = $line]" | grep -q '(no matches)' | |
then | |
augtool -e -At "Simplelines incl $src" <<EOF | |
ins 01 after /files$src | |
set /files$src/01 $line | |
save | |
EOF | |
fi | |
# This will work with augeas-1.11.0 (not released yet) | |
# We disable it with 'if false' | |
# See https://github.com/hercules-team/augeas/pull/563 | |
if false | |
then | |
if ! augmatch -q -l Simplelines -m "*[$line]" $src | |
then | |
augtool -e -At "Simplelines incl $src" <<EOF | |
ins 01 after /files$src | |
set /files$src/01 $line | |
save | |
EOF | |
fi | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Basic example file for Simplelines lens | |
line 1 value # comment line 1 | |
line 2 value # comment line 2 | |
Include /some/file | |
Include /some/other/file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment