Sponsored Content
Top Forums Shell Programming and Scripting Need To Delete Lines Based On Search Criteria Post 302770582 by angshuman on Sunday 17th of February 2013 08:51:43 AM
Old 02-17-2013
Need To Delete Lines Based On Search Criteria

Hi All,

I have following input file. I wish to retain those lines which match multiple search criteria. The search criteria is stored in a variable seperated from each other by comma(,).

HTML Code:
SEARCH_CRITERIA = "REJECT, DUPLICATE" 

Input File:

ERROR,MYFILE_20130214_11387,9,37.75
REJECT,MYFILE_20130214_12486,1,20
DUPLICATE,MYFILE_20130214_12486,8,17.75
REJECT,MYFILE_20130214_14903,9,37.75
ERROR,MYFILE_20130214_17108,9,37.75
DUPLICATE,MYFILE_20130214_1811,0,0
My ouput file should look like below:

HTML Code:
REJECT,MYFILE_20130214_12486,1,20
DUPLICATE,MYFILE_20130214_12486,8,17.75
REJECT,MYFILE_20130214_14903,9,37.75
DUPLICATE,MYFILE_20130214_1811,0,0
Thanks & Regards
Angshuman
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Select records based on search criteria on first column

Hi All, I need to select only those records having a non zero record in the first column of a comma delimited file. Suppose my input file is having data like: "0","01/08/2005 07:11:15",1,1,"Created",,"01/08/2005" "0","01/08/2005 07:12:40",1,1,"Created",,"01/08/2005"... (2 Replies)
Discussion started by: shashi_kiran_v
2 Replies

2. Shell Programming and Scripting

remove lines based on score criteria

Hi guys, Please guide for Solution. PART-I INPUT FILE (has 2 columns ID and score) TC5584_1 93.9 DV161411_2 79.5 BP132435_5 46.8 EB682112_1 34.7 BP132435_4 29.5 TC13860_2 10.1 OUTPUT FILE (It shudn't contain the line ' BP132435_4 29.5 ' as BP132435 is repeated... (2 Replies)
Discussion started by: smriti_shridhar
2 Replies

3. Shell Programming and Scripting

Append specific lines to a previous line based on sequential search criteria

I'll try explain this as best I can. Let me know if it is not clear. I have large text files that contain data as such: 143593502 09-08-20 09:02:13 xxxxxxxxxxx xxxxxxxxxxx 09-08-20 09:02:11 N line 1 test line 2 test line 3 test 143593503 09-08-20 09:02:13... (3 Replies)
Discussion started by: jesse
3 Replies

4. Shell Programming and Scripting

Delete new lines based on search criteria

Hi all! A bit of background: I am trying to create a script that formats SQL statements. I have gotten so far as to add new lines based on certain match criteria like commas, keywords etc. In the process, I end up adding newlines where I don't want. For example: substr(colName, 1, 10)... (3 Replies)
Discussion started by: jayarkay
3 Replies

5. Shell Programming and Scripting

awk search & delete located criteria

Guys, I manages to get awk to search and print the files that I want to delete. However I am stuck on the delete portion. Here is the command that I am using to fins these files. find /usr/local/apache/conf/vhosts/ -type f | awk '/e$/' The output is perfect. The files look like so: ... (4 Replies)
Discussion started by: jaysunn
4 Replies

6. Shell Programming and Scripting

Extract data based on specific search criteria

I have a huge file (about 2 millions records) contains data separated by “,” (comma). As part of the requirement, I can't change the format. The objective is to remove some of the records with the following condition. If the 23rd field on each line start with 302 , I need to remove that from the... (4 Replies)
Discussion started by: jaygamini
4 Replies

7. Shell Programming and Scripting

Merging Lines based on criteria

Hello, Need help with following scenario. A file contains following text: {beginning of file} New: This is a new record and it is not on same line. Since I have lost touch with script take this challenge and bring all this in one line. New: Hello losttouch. You seem to be struggling... (4 Replies)
Discussion started by: losttouch
4 Replies

8. Shell Programming and Scripting

Select lines from a file based on a criteria

Hi I need to select lines from a txt file, I have got a line starting with ZMIO:MSISDN= and after a few line I have another line starting with 'MOBILE STATION ISDN NUMBER' and another one starting with 'VLR-ADDRESS' I need to copy these three lines as three different columns in a separate... (3 Replies)
Discussion started by: Tlcm sam
3 Replies

9. Shell Programming and Scripting

Copying section of file based on search criteria

Hi Guru's, I am new to unix scripting. I have a huge file with user details in it(file2) and I have another file with a list of users(file1). Script has to search a user from file1 and get all the associated lines from file2. Example: fiel1: cn=abc cn=DEF cn=xyx File 2: dn:... (10 Replies)
Discussion started by: Samingla
10 Replies

10. Shell Programming and Scripting

Delete duplicate row based on criteria

Hi, I have an input file as shown below: 20140102;13:30;FR-AUD-LIBOR-1W;2.495 20140103;13:30;FR-AUD-LIBOR-1W;2.475 20140106;13:30;FR-AUD-LIBOR-1W;2.495 20140107;13:30;FR-AUD-LIBOR-1W;2.475 20140108;13:30;FR-AUD-LIBOR-1W;2.475 20140109;13:30;FR-AUD-LIBOR-1W;2.475... (2 Replies)
Discussion started by: shash
2 Replies
SEARCHMONKEY(1) 					      General Commands Manual						   SEARCHMONKEY(1)

NAME
SEARCHMONKEY - search files using regular expressions aiming to replace find/grep tools INTRODUCTION
searchMonkey is a GTK+ application designed to replace the find/grep command line tools. The aim of this utility it to provide fast, slick text search ability to the GTK community. The User Interface This section describes every button, window, table and what it shows or does. File Menu New Starts a brand new search (losing previous search history). Open Criteria Opens a previously saved search criteria. Close Close a child criteria window, but not the main application. Save Criteria Saves a search criteria (excluding the results). Save Criteria As As Save Criteria, but brings up a save-as dialog. Save Results Saves the results to a custom XML file. Only available when search complete. Print Print the search results in a well formatted way. Print Preview Brings up a display of what would have been printed. Print Setup Brings up the system's printer setup dialog. Edit Menu Word Wrap When selected, allow the results text to wrap instead of keeping to strict lines. Set Font Brings up a font dialog to adjust the results window base font. Set Color Brings up a color selection dialog to adjust the highlight colour for the match results. Clear History Remove search history from drop down criteria. Select All Selects all file name matches in the left results pane. Delete Deletes the selected file name(s) forever (once confirmed). Copy Copies the selected file name(s) to clipboard. View Menu Toolbar If selected, the tool bar is shown. Status Bar If selected, the status bar is shown. Sort by Within sub-menu, choose sort criteria e.g. file name, file size, modified date. Search Menu Start Starts the search. Stop Stops the search. Enabled when search is running. One phase searching Allows content matches to be displayed immediately, instead of waiting for all files to be found. Configuration Brings up application configuration dialog. Test Menu Reg. Expression Allows a regular expression to be entered, along with sample text as a way of checking that your expression returns the expected results. Window Menu SearchXX Allows quick switching between open search criteria/results windows. Help Menu Description User Guide Brings up this web address from your default browser Support Brings up the searchMonkey support page from Sourceforge About Brings up a dialog showing version number, license, and author's email. The Toolbar Can be hidden from the main-menu (view->toolbar). New Starts a brand new search (losing previous search history). Open Opens a previously saved search criteria. Save Saves a search criteria (excluding the results). Save Results Saves the results to a custom XML file. Only available when search complete. Play Start the search. Stop Stop the search. Only available when search in progress. Print Print the search results in a well formatted way. Forums Starts a new browser instance to the searchMonkey Forums The Advanced Search Tab Displayed when Expert User is enabled. File Name Type a new regular expression for file name searching. Containing Text Type a new regular expression for (text-only) contents searching. Disable this field with check button. Expr. Wizard Brings up a regular expression helper dialog. Makes typing new regular expressions easier. Look In Type a new starting location for search. Disable recurse directories with check button. Open/Multi Brings up a folder search dialog. Multi allows multiple folders to be selected for expert searches. More/Less Than Type a file size (in KBytes) to narrow searches to files less-than and/or more-than specified size. More/Less Than Type a date expression (e.g. dd/mm/yyyy or dd mmm yyyy) to narrow searches to files modified before and/or after specified date. The Options Tab Available at all times from the main screen. Specifies Not Expression Inverts the search i.e. finds everything except your regular expression. Status bar shows [INV] to indicate inverted. Match case When disabled allows case insensitive searching of file names and/or content. Regular Expression When selected allows regular expressions to be used. DOS Expression When selected allows file names to be found using DOS/Glob style pattern matching i.e. * and ?. Open/Multi Brings up a folder search dialog. Multi allows multiple folders to be selected for expert searches. More/Less Than Type a file size (in KBytes) to narrow searches to files less-than and/or more-than specified size. More/Less Than Type a date expression (e.g. dd/mm/yyyy or dd mmm yyyy) to narrow searches to files modified before and/or after specified date. File Name Results This pane is only filled when matches are found. Left clicking on a match will bring up content matches (displayed in the Context Results pane, if any), and right-clicking the row will bring up a sub-menu. Right Click Menu Open Opens the file name in your preferred text editor. See configuration. Copy Copies the full file name into the clipboard for use elsewhere. Delete Deletes the selected file forever, once confirmed. Explore Opens your preferred file browser that contains the selected file Context Results This pane is only filled when text matches are found, and a result has been selected. The line that matches the search expression will be shown in full, and the actual match text will be highlighted. Once text has been selected with the left-button, the right button will allow copy options, or select-all to be performed on the text. These allow text to be copied from the results window, and pasted elsewhere. Advanced File Name and/or Contents Searching To find files, using regular expressions can be achieved by filling out the File Name and Look In boxes. The starting file name can be typed, copied or selected by using the Open dialog. To search a single folder, uncheck the Search Subfolders box. If you want to find a specific regular expression within a text file, then fill out the Containing Text box with a regular expression. Note: significantly less files are shown when Containing Text is added because binary files are skipped. For a more specific search, add in min/max file size, and the after/before modified date (if known). Once ready, press Play to start the search process. Results (if any) immediately start appearing in the File name results table, and once complete the total number of matches is shown in the status bar Status Bar Describes what is currently going on. * Phase 1 searching is the gathering of files that match the filename, size and modified date criteria. * Phase 2 searching is the internal checking of text files to match the search strings. * Upon completion, the number of hits is displayed, along with whether this was an inverse filename search [inv] or [cancelled] by the user Tips and Tricks This section gives examples of some cool things to do with searchMonkey. Regular Expressions Some examples of regular expressions are given here: (.[ch])$ Finds all of the C source code, plus headers. ^(make) Finds every make file instance. ^(void function_name)(;)$ Finds a function declaration, as opposed to the definition ([a-zA-Z0-9s]+) Highlights all text within brackets SearchMonkey User Guide Online To view the same guide in HTML please visit <http://searchmonkey.sourceforge.net/index.php/SearchMonkey_User_Guide> AUTHOR
This manual page was written by Varun Hiremath <varunhiremath@gmail.com>, for the Debian project (but may be used by others). September 12, 2006 SEARCHMONKEY(1)
All times are GMT -4. The time now is 02:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy