01-20-2020
This would be easy if you did not try to make these text processing tasks "one liners" and just write
the (few lines) code to process the file one line at a time, using any programming language you like.
Basically, if you just processed this text in a loop, reading each line at a time, matching flags and setting patterns, you could have easily processed this file. (Or read the file into an array of lines of text.)
The issue, as I see it, is you (not only you, but many) are falling into the "trap" of looking for "one liners" instead of just writing a small program of a few lines which does the trick.
You are not the only person who falls in to the trap of thinking that everything has to be a "one liner" but this will cause you to waste time when you could write a few lines of code in any programming language and most shell scripts to:
- Read the file into an array of lines.
- Process each line and search for your beginning <VirtualHost tag and set a flag.
- When the flag is set, search and match the other string(s) (SSLInsecureRenegotiation ... blah blah) and put the match(es) in an array.
- Stop processing after the end tag </VirtualHost is matched.
This is only a few lines of code and is very easy for you (or anyone with minimal programming skills) to write and you could have easily written this code in the time it takes to search for a "one liners" to do the job.
I'm not trying to give you a hard time and I like your posts; but I'm just saying. For a guy with nearly 1000 posts here; you should just write a handful of lines of code and process this versus wasting your time searching for the perfect "one-liner" REGEX.
Cheers.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi All,
I want to search all the ksh scripts that has following details.
1. Search for "exit 0"
2. Search for "sqlldr" or sqlplus"
3. In the above files i want to search for all the script that has no "case" in it.
Please advice.
Thanks,
Deep (2 Replies)
Discussion started by: deepakpv
2 Replies
2. Shell Programming and Scripting
I need to extract the last block of /== START OF SQLPLUS ==/ and /== END OF SQLPLUS ==/. The logifle is written to several times in a day using >> to append. I need a solution using grep/sed.
logfile looks like this
START OF LOGFILE
/== START OF SQLPLUS ==/
ERROR
/== END OF SQLPLUS... (5 Replies)
Discussion started by: hanton
5 Replies
3. Shell Programming and Scripting
Can someone help me? I been figuring out how I can search and extract a complicated search string from a file. The whole string is delimited by a period. And the file where I'm searching is composed of differnt string such as that. For example, I have this search string:
and I have a file... (3 Replies)
Discussion started by: Orbix
3 Replies
4. Shell Programming and Scripting
Hi
I want to search multiple strings in a file . But the search should start with "From" Keyword and end with before "Where" keyword.
Please suggest me.
Thanks (2 Replies)
Discussion started by: sboss
2 Replies
5. Shell Programming and Scripting
Hi All,
We have a file "Customers.lst". It contains list of all the Customers.
There is directory which has number of text files and each file containing name of defaulter customers.
We want to search for all the customers available in "Customers.lst" file against the list of files... (8 Replies)
Discussion started by: arunorcl
8 Replies
6. Shell Programming and Scripting
Hi There...
I need to serach and replace a strings in a text file.
My file has; books.amazon='Let me read' and the output needed is
books.amazon=NONFOUND
pls if anybody know this can be done in script sed or awk.. i have a list of different strings to be repced by NONFOUND.... (7 Replies)
Discussion started by: Hiano
7 Replies
7. Shell Programming and Scripting
I have a file search_strings.txt filled with search strings which have a blank in between and look like this:
S. g. Erh.
o. J.
v. d. Chijs
g. Ehr.I would like to search the strings in the second given Textfile.txt and it shall return the column number.
Can anybody help with the correct... (3 Replies)
Discussion started by: sdf
3 Replies
8. Shell Programming and Scripting
Hi guys,
I have a text file named file1.txt that is formatted like this:
001 , ID , 20000
002 , Name , Brandon
003 , Phone_Number , 616-234-1999
004 , SSNumber , 234-23-234
005 , Model , Toyota
007 , Engine ,V8
008 , GPS , OFF
and I have file2.txt formatted like this:
... (2 Replies)
Discussion started by: An0mander
2 Replies
9. UNIX for Beginners Questions & Answers
I have a data file, file1.txt, such as the following:
1,2 "TWRTW", "TWRH/"
1,2 "JHGH", "HGJ
1,2 "JWMM", "JWMM"
1,2 "W", "W"
1,2 "LJLH", "LJLH/"
1,3 "W", "W"
1,3 "HJH", "HJJ
I have another file, file2.txt, that contains... (3 Replies)
Discussion started by: jvoot
3 Replies
10. Shell Programming and Scripting
I have a file conatining the below:
---
10.9.16.116:
/tmp/5835113081224811756.jar:
hash: e6df90d38fa86f0e289f73d79cd2cfd2a29954eb
/tmp/4603745991442278706.jar:
hash: e6df90d38fa86f0e289f73d79cd2cfd2a29954eb
10.9.14.126:
/tmp/conf/extra/httpd-ssl.conf:
hash:... (1 Reply)
Discussion started by: mohtashims
1 Replies
LEARN ABOUT NETBSD
apropos
APROPOS(1) BSD General Commands Manual APROPOS(1)
NAME
apropos -- search the complete content of all man pages
SYNOPSIS
apropos [-123456789Ccp] [-n Number of results] [-S machine] [-s section] query
DESCRIPTION
The apropos utility performs a full text search over the complete content of all man pages. It uses the FTS engine of Sqlite to perform the
search. The database is created with the help of makemandb(8) utility.
This implementation of the apropos utility is more sophisticated than the classical version of apropos. Like modern search applications, it
uses advanced techniques like stemming and term weighting to rank the matching results in decreasing order of relevance. By default apropos
will only display the top 10 matches in the output.
Quotes are optional for specifying multiword queries.
It supports the following options:
-1 Search only within section 1 manual pages.
-2 Search only within section 2 manual pages.
-3 Search only within section 3 manual pages.
-4 Search only within section 4 manual pages.
-5 Search only within section 5 manual pages.
-6 Search only within section 6 manual pages.
-7 Search only within section 7 manual pages.
-8 Search only within section 8 manual pages.
-9 Search only within section 9 manual pages.
-C Do not show the context of the match.
-c Do show the context of the match (default).
-n Output up to the specified number of search results. The default limit is 10.
-p Display all matching results and pipe them through a pager (defaulting to more(1)).
-S machine
Limit the search to the pages for the specified machine architecture. By default pages for all architectures are shown in the search
results.
-s section
Restrict the search to the specified section of the manual. By default, pages from all section are shown. This option is for back-
wards compatibility with the classic version of apropos, using it is equivalent to using the [123456789] options directly.
FILES
/var/db/man.db The Sqlite FTS database which contains an index of the manual pages.
SEE ALSO
man(1), whatis(1), makemandb(8)
HISTORY
The apropos command appeared in 3.0BSD. It was rewritten in NetBSD 6.0 to support full text search using Sqlite.
AUTHORS
Abhinav Upadhyay
BSD
April 21, 2012 BSD