|ainsl(1)||General Commands Manual||ainsl(1)|
NAME¶ainsl - AppendIfNoSuchLine
SYNOPSIS¶ainsl [options] FILE LINE [PATTERN]
DESCRIPTION¶Add LINE to the end of FILE if this file does not contain this 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 given, LINE is used instead for matching a line in FILE. Then LINE may also contain the anchors '^' and '$' which are only treated specialy 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.
- Autocreate file if it does not exist.
- Create debugging output.
- Show help, version and summary of options.
- Print the actions, but do not execute them.
- Quote all metacharacters in pattern. Uses perl's \Q function.
- Quote * and + metacharacters in pattern.
- Convert white space in LINE or PATTERN to '\s+' regexp for matching.
- Don't prepend '$AINSL_TARGET/' to filename, even if it is set.
- Create verbose output.
NOTES¶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.
EXAMPLES¶ainsl -v /etc/fstab '/dev/fd0 /floppy auto users,noauto 0 0'
Append the entry for the floppy device to /etc/fstab, if this line isn't already included. If this line in 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.
- Success: Either FILE contains the LINE/PATTERN or LINE was appended to FILE.
- Permissions do not allow writing to FILE and LINE/PATTERN was not found in file.
- FILE cannot be written because the filesystem has no space and LINE/PATTERN was not found in file.
- FILE cannot be written because the filesystem is read-only and LINE/PATTERN was not found in file.
NOTES¶This is a similar function to AppendIfNoSuchLine from cfengine(8).
SEE ALSO¶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.
AUTHOR¶Thomas Lange <firstname.lastname@example.org>
|8 march 2012||FAI 4|