Sponsored Content
Top Forums Shell Programming and Scripting Search for a text between two strings in a file using regex Post 303043159 by RudiC on Monday 20th of January 2020 07:20:42 AM
Old 01-20-2020
I can't see what program your regex was written for. Pls learn to mention ALL relevant details in your spec. For sed, try
Code:
sed -n '/<VirtualHost/,/<\/VirtualHost>/ {/^[^#]*SSLInsecureRenegotiation.*Off/p}' file
SSLInsecureRenegotiation Off
SSLInsecureRenegotiation Off

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to search multiple strings in a file

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

search file between last occurence of 2 strings

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

Search complicated strings on file

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

Search multiple Strings in a File

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

Best Alternative to Search Text strings in directory

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

Search replace strings between single quotes in a text file

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

Search strings from array in second file

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

Read in search strings from text file, search for string in second text file and output to CSV

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

Using strings in one file as regex to search field of another file

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

Need grep regex to extract multiline text between two strings

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
TXT2REGEX(1)						      General Commands Manual						      TXT2REGEX(1)

NAME
txt2regex - a Regular Expression Wizard, written with bash2 builtins SYNOPSIS
txt2regex txt2regex --nocolor|--whitebg txt2regex --all|--prog <p1,p2,...,pN> txt2regex --showmeta|--showinfo <program> txt2regex --make <target> txt2regex --history <value> DESCRIPTION
txt2regex is a Regular Expression "wizard", all written with bash2 builtins, that converts human sentences to regexes. With a simple interactive interface, you just answer to questions and build your own regex for a large variety of programs, like awk, emacs, grep, perl, php, procmail, python, sed and vim. There are more than 20 supported programs. It's bash so download and run, no compilation needed. Please visit the program homepage at http://txt2regex.sf.net. OPTIONS
--all works with all registered programs --help prints the help message and quit --history <value> prints to STDOUT a regex from a history data --make <target> prints a ready regex for a common pattern --nocolor self-explanatory --prog <p1,p2,...> choose which programs to use (separated by commas) --showinfo <program> prints regex info about the program --showmeta prints a complete metachar table for all programs --version prints the program version and quit --whitebg colors adjusted to white background terminals By default, all options are turned OFF. Just call it with no options to launch the default interactive interface. DETAILS
--all is cool but requires lots of lines (~35) --nocolor is strong, so it kills --whitebg --showmeta rules, try it --showinfo uses reverse video output, --nocolor turns it off --history is getting useful, stay tunned --make is a remedy for headaches --prog is nice to use your favorite programs, mix it with --make and --history EXAMPLES
Calling the program on the default interactive interface $ txt2regex Calling the program on a white terminal $ xterm -fg black -bg white ; txt2regex --whitebg Getting information $ txt2regex --showmeta Getting specific information $ txt2regex --showinfo sed Calling it for specific programs $ txt2regex --prog vim,sed,grep,python Applying a history data $ txt2regex --history '16421x:01x:' Getting ready regexes! $ txt2regex --make hour $ txt2regex --make number3 --prog perl $ txt2regex --make date2 --all INTERFACE
The program interface is simple and easy to use. This is its contents: +---------------------------------------+ | -> Top menu | | -> Group menu | | | | -> Regexes of the programs selected | | ... | | ... | | | | -> History | | -> Your prompt | | | | -> The question | | -> The answers | | ... | | ... | +---------------------------------------+ All the basic commands can be used on the numeric pad on the keyboard, but remember to turn ON the NumLock key. Command Description . Quit the program (with confirmation) 0 Reset the Regular Expression 1-9 Answers the questions * Toggles color ON/OFF / Add/remove programs on/from the list | Insert an alternation (where allowed) ( Open a new group (where allowed) ) Close the opened group (if any) BUGS
Bug reports and contributions are VERY welcome! Please send them to the author. AUTHOR
Written and maintained by Aurelio Marinho Jargas <verde@aurelio.net> COPYRIGHT
Copyright (C) 2000, 2001, 2002, 2003, 2004 Aurelio Marinho Jargas This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU- LAR PURPOSE. September, 28th - 2004 TXT2REGEX(1)
All times are GMT -4. The time now is 03:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy