ainsl(1) | General Commands Manual | ainsl(1) |
ainsl - AppendIfNoSuchLine
ainsl [options] FILE LINE [PATTERN]
Add LINE to the end of FILE if the file does not contain the line already. If PATTERN is given, then the LINE is only appended if PATTERN is not found in the file.
Since ainsl is written in Perl, you can use Perl's regular expressions in PATTERN. If PATTERN is not supplied, LINE is used instead for matching a line in FILE. LINE may also contain the anchors '^' and '$' which are only treated specially at the beginning or end of the pattern and are used for matching, not when adding the line. Additionally, the following characters are escaped in LINE: ( ) +
The exit code returned by ainsl is 0 on success and non-zero on error. See the section EXIT CODES.
If the variable AINSL_TARGET is defined, its value will become the prefix for the filename. This is used in FAI for changing files in /target without specifying /target in the file name.
ainsl -v /etc/fstab '/dev/fd0 /floppy auto users,noauto 0 0'
Append the entry for the floppy device to /etc/fstab, if the line isn't already present. If the line is already in /etc/fstab, but is commented out it will not be added unless you extend the pattern to match only at the beginning of the line:
ainsl -v /etc/fstab '^/dev/fd0 /floppy auto users,noauto 0 0'
ainsl -s /etc/exports '/srv/www @linuxhosts(async,rw) backup(async,ro)'
Add exports entry without exactly matching spaces.
This is a similar function to AppendIfNoSuchLine from cfengine(8).
This program is part of FAI (Fully Automatic Installation). See the FAI manual for more information on how to use ainsl. The FAI homepage is https://fai-project.org.
Thomas Lange <lange@cs.uni-koeln.de>
8 march 2012 | FAI 4 |