Awk script that outputs multi-line or single-line --from
--till
matches
Awk or GAwk installed and executable under /usr/bin/awk
file path.
Download the source code of this repository...
_downloads_path="${HOME}/git/hub/awk-utilities"
mkdir -vp "${_downloads_path}"
cd "${_downloads_path}"
git clone [email protected]:awk-utilities/match-from-till.git
Symbolically link to PATH
accessible location...
_script_path="${_downloads_path}/match-from-till/match-from-till.awk"
ln -s ${_script_path} ${HOME}/bin/
Parse files with --from=
--till=
command line options and any number of files...
match-from-till.awk --from="start" --till="end" file-one.ext file-two.ext...
This script buffers lines between --from
and --till
matches; memory enough to handle the largest match is likely needed, and multi-file inputs may cause matching across document breaks
Lines are matched with ~
allowing for patterns to be passed with the --from
and --till
options...
match-from-till.awk --from="^start" --till="^end" <<EOF
start
middle
end
start middle end
EOF
This project is not feature complete but does function; Pull Requests and Issues are welcomed regarding what features need to be added.
-
https://www.gnu.org/software/gawk/manual/html_node/Truth-Values.html
-
https://www.gnu.org/software/gawk/manual/html_node/Boolean-Ops.html
-
https://www.gnu.org/software/gawk/manual/html_node/Delete.html
-
https://www.gnu.org/software/gawk/manual/html_node/ARGC-and-ARGV.html#ARGC-and-ARGV
-
https://www.unix.com/shell-programming-and-scripting/242764-begin-end-blocks-awk-confused.html
-
https://www.linuxquestions.org/questions/programming-9/how-to-read-a-file-inside-awk-874908/
Legal bits of Open Source software
Match From Till documentation
Copyright (C) 2019 S0AndS0
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation; version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.