ainsl(1)
β¨ ainsl(1) β General Commands Manual β¨
π NAME
ainsl β AppendIfNoSuchLine π
π¦ SYNOPSIS
ainsl [options] FILE LINE [PATTERN]
πΈ DESCRIPTION
Okay so bestie, ainsl is literally the line-adding queen π. It tacks LINE onto the very end of FILE, but only if that line isn't already hanging out in there. If you pass a PATTERN, then LINE only gets appended when PATTERN is nowhere to be found in the file. No cap, that's the whole vibe β¨
Since ainsl is written in Perl, you can use Perl's regular expressions in PATTERN π
. If you don't supply a PATTERN, then LINE gets used for the matching instead π«Ά. Now here's the lowkey tricky part: LINE can include the anchors ^ and $, but they only count as special when they're at the very beginning or very end of the pattern π. They're for matching only, so they won't show up in the line that gets added. Also, the following characters get escaped in LINE: ( ) + π
The exit code ainsl returns is 0 on success and non-zero on error. Peep the section EXIT CODES for the deets π§
π OPTIONS
-aβ Autocreate the file if it doesn't exist yet π-Dβ Create debugging output π₯-hβ Show help, version, and a summary of options π-nβ Print the actions, but don't actually execute them π-Qβ Quote all metacharacters in the pattern. This uses Perl's\Qfunction π-qβ Quote*and+metacharacters in the pattern π-sβ Convert whitespace inLINEorPATTERNinto the'\s+'regexp for matching π¦-Nβ Don't prepend'$AINSL_TARGET/'to the filename, even if it's set π«Ά-vβ Create verbose output πΈ
β NOTES
If the variable AINSL_TARGET is defined, its value becomes the prefix for the filename. This is what FAI uses to change files in /target without having to type /target in the file name π§β¨
π EXAMPLES
ainsl -v /etc/fstab '/dev/fd0 /floppy auto users,noauto 0 0'
Here we append the floppy entry to /etc/fstab, if the line isn't already there. If the line is already in /etc/fstab but it's commented out, it won't get 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 the exports entry without needing the spaces to match exactly π₯
π¨ EXIT CODES
0β Success! EitherFILEalready contains theLINE/PATTERN, orLINEgot appended toFILEπ13β Permissions don't allow writing toFILE, and theLINE/PATTERNwasn't found in the file π ββοΈ28βFILEcan't be written because the filesystem has no space left, and theLINE/PATTERNwasn't found in the file π30βFILEcan't be written because the filesystem is read-only, and theLINE/PATTERNwasn't found in the file π
β NOTES
This is a similar function to AppendIfNoSuchLine from cfengine(8) π
π¦ SEE ALSO
This program is part of FAI (Fully Automatic Installation). Check out the FAI manual for more on how to use ainsl. The FAI homepage is https://fai-project.org πΈ
π«Ά AUTHOR
Thomas Lange <lange@cs.uni-koeln.de> π
Ta-da, that's the whole manual, bestie! π Fresh from FAI 4, dated 8 March 2012, and rendered in ainsl(1) glory. Stay iconic π
β¨
π¦ where this page comes from
- debian bookworm: fai-client 6.0.3+deb12u1 Β· GPL-2.0-or-later
- debian trixie: fai-client 6.4.3 Β· GPL-2.0-or-later
- ubuntu noble: fai-client 6.0.5ubuntu1 Β· GPL-2.0-or-later
- ubuntu resolute: fai-client 6.4.3ubuntu1 Β· GPL-2.0-or-later
- ubuntu stonking: fai-client 6.6ubuntu1 Β· GPL-2.0-or-later
- π girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms