Sponsored Content
Top Forums Shell Programming and Scripting Find all lines in file such that each word on that line appears in at least n lines of the file Post 302999212 by uncleMonty on Thursday 15th of June 2017 09:43:24 AM
Old 06-15-2017
Thank you Rudi. I should learn awk, shouldn't I. That is a good way to count the occurrences. Is there a way, having counted the occurrences, to echo an entire line, if and only if the 1st 3rd 5th and 7th field of that line all appear at least 4 times in the file? (For the smaller sample data I posted, it would find an answer if we searched for lines whose entries all appear at least twice, instead of four times.)

You are correct not to worry about repeats within a single line, this is ruled out by construction of the data.

P.s. apologies if I overreacted--I think what was irritating was not that someone would want to make sure my question wasn't homework (I agree that a forum can quickly become useless to experts if it is overrun by homework questions), but instead the order to "please explain the company you work for and the nature of the problem you are working on", not only because it is intrusive, but because it suggests that only people who work for a company with a work-related problem can legitimately ask for scripting assistance here. But: your forum, your rules, ok.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shellscript to find a line in between a particular set of lines of a text file

i have a file a.txt and following is only one portion. I want to search <branch value="/dev36/AREA/" include="yes"></branch> present in between <template_file name="Approve External" path="core/approve/bin" and </template_file> where the no of lines containing "<branch value= " is increasing ... (2 Replies)
Discussion started by: millan
2 Replies

2. Shell Programming and Scripting

Find 5 lines and replace with 18 line in sql file where it contains multiple blocks.

My sql file xyz_abc.sql in this file there are multiple sql block in this block I need to find the following block rem Subset Rows (&&tempName.*) CREATE VIEW &&tempName.* AS SELECT * FROM &&tempName.* WHERE f is not null and replace with following code rem Subset Rows... (9 Replies)
Discussion started by: Zaheer.mic
9 Replies

3. Shell Programming and Scripting

Unix help to find blank lines in a file and print numbers on that line

Hi, I would like to know how to solve one of my problems using expert unix commands. I have a file with occasional blank lines; for example; dertu frthu fghtu frtty frtgy frgtui frgtu ghrye frhutp frjuf I need to edit the file so that the file looks like this; (10 Replies)
Discussion started by: Lucky Ali
10 Replies

4. UNIX for Dummies Questions & Answers

find uniq lines in file, using the first field of line

Hello all, new to unix and have just found the forum. I think I will be here quite often, and hope that in time i will be able to provide soem help, role on not being a newbie anymore :) I have a question which iI am hoping someone could help me with. If i have a file with lines in in thus... (8 Replies)
Discussion started by: grom
8 Replies

5. Shell Programming and Scripting

print lines from a file containing key word

i have a file containing over 1 million records,and i want to print about 300,000 line containing a some specific words. file has content. eg 1,rrt,234 3,fgt,678 4,crf,456 5,cde,drt 6,cfg,123 and i want to print the line with the word fgt,crf this is just an example,my file is so... (2 Replies)
Discussion started by: tomjones
2 Replies

6. UNIX for Dummies Questions & Answers

how to find a word in a file that appears next to a given keyword

Hi Experts, I have a file which contains some text. i need to print the word next to a given keyword. Please help. Ex: test.txt ===================== NEXT HOST ===================== AEADBAS001 access-list 1 permit xxxxxxxxxxxxxx ip access-list extended BLA_Outgoing_Filter... (6 Replies)
Discussion started by: mwrg
6 Replies

7. Shell Programming and Scripting

Get last lines of file after last line with word TEST

i need to get least lines of file after last word TEST in file, and send that lines to mail example of file structure: TEST 10.10.2010 jdfjdnjfndjfndnfkdk djfjdnfjkdjkfnjkdfk jdfjdjfnjdjnfjkdnfjk TEST 11.10.2010 jdjfnjdnfdkdfjdfjdnk jdnfjdnjkfndnfjdnfjk fjdnfjkndnfdfnjdnfjk TEST... (6 Replies)
Discussion started by: waso
6 Replies

8. Shell Programming and Scripting

Read all lines after a string appears in the file.

Hi All, I want to read all lines after a perticular string {SET UP VALUES}apprears in the file. SET UP values contains direcory, number of days and file type. Step1: Read all lines below SET UP VALUES string. Step2: If set up values are not present in each record then read from default... (4 Replies)
Discussion started by: Nagaraja Akkiva
4 Replies

9. UNIX for Advanced & Expert Users

How to find a string in a line in UNIX file and delete that line and previous 3 lines ?

Hi , i have a file with data as below.This is same file. But actual file contains to many rows. i want to search for a string "Field 039 00" and delete that line and previous 3 lines in that file.. Can some body suggested me how can i do using either sed or awk command ? Field 004... (7 Replies)
Discussion started by: vadlamudy
7 Replies

10. UNIX for Beginners Questions & Answers

Search for word in huge logfile and need to continue to print few lines from that line til find date

Guys i need an idea for one logic..in shell scripting am struggling with a logic...So the thing is... i need to search for a word in a huge log file and i need to continue to print few more lines from that line and the consecutive line has to end when it finds the line with date..because i know... (1 Reply)
Discussion started by: Prathi
1 Replies
MRTG-FORUM(1)							       mrtg							     MRTG-FORUM(1)

NAME
mrtg-forum - Interactive Help for MRTG users SYNOPSIS
There is a lot of written documentation for mrtg, but nevertheless you may have a problem where you can't find the solution. In this case some Human Help may be necessary. With MRTG there are several ways to get Humans to help you. MAILING-LIST There are three mailing lists for MRTG available. mrtg for discussion among mrtg users. mrtg-announce for announcements regarding new versions of mrtg related software. mrtg-developers for discussion among people who write software in connection with mrtg or who hack mrtg itself. THE RULES Please note that the memebers of the mrtg mailinglist value politeness highly. This means behave in a way you would like others to behave towards you. o No shouting. (NO CAPS) o No rude language o No demands. everybody is on the list out of their own free will. If you do not get an answer to your question, chances are high that you did not give sufficent details about the nature of your problem or that the answer to your problem is in the documentation. o If you do not follow the rules you will be unsubscribed from the list with no further questions asked. o Decisions about your unsubscription from the list will be taken by Alex van den Bogaerdt <alex at ergens.op.het.net> Paul C. Williamson <pwilliamson at MANDTBANK.COM> If you feel that you have been treated unfairly, you may send mail to me and explain the situation. Tobi Oetiker <tobi@oetiker.ch> SUBSCRIBING These lists are managed by a mailing-list management program (listar). It allows you to subscribe to these lists by sending a message with the subject: subscribe to the following address: listname-request@lists.oetiker.ch You will then get a message asking you to confirm your subscription. For posting to the lists use the following address listname@lists.oetiker.ch Note that only people who are subscribed to the list can post. Further information about the usage of the mailing lists is available by sending a message with the subject line help to either one of the request addresses. There is also a webinterface to the lists on http://lists.oetiker.ch List archives are on http://www.mail-archive.com/index.php?hunt=mrtg and http://gmane.org/find.php?list=mrtg NEWSGROUP
For discussion of MRTG or related topics on the Usenet, please send your posts to: news:comp.dcom.net-management Many MRTG users are in this forum and will help you. You can also find an archive of past activity from this Newsgroup on: http://groups.google.com/group/comp.dcom.net-management IRC Channel For discussion of MRTG and related topics on IRC, the `#mrtg' channel on EFNet has been created. More information can be found at http://mrtg.easymac.org MRTG Japan There is a special Mailinglist for MRTG Users in Japan. It carries translations of the traffic from MRTG-ANNOUNCE as well as updates on the Japanese Translation of the MRTG documentation. Go to http://www.mrtg.jp/ for further Information. MRTG Turkiye There is a special Mailinglist for MRTG Users in Turkey. Go to http://groups.yahoo.com/group/mrtg-turkiye/ for more information. AUTHOR
Tobias Oetiker <tobi@oetiker.ch> and many contributors 2.16.2 2008-05-16 MRTG-FORUM(1)
All times are GMT -4. The time now is 04:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy