Sponsored Content
Full Discussion: Count pattern line by line
Top Forums UNIX for Beginners Questions & Answers Count pattern line by line Post 303043518 by rbatte1 on Thursday 30th of January 2020 08:39:21 AM
Old 01-30-2020
Hello ctrld,

I have a few to questions pose in response first:-
  • Is this homework/assignment? There are specific forums for these.
  • What have you tried so far?
  • What output/errors do you get?
  • What OS and version are you using?
  • What are your preferred tools? (C, shell, perl, awk, etc.)
  • What logical process have you considered? (to help steer us to follow what you are trying to achieve)
Most importantly, What have you tried so far?

There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.


We're all here to learn and getting the relevant information will help us all.


As a first thought, you might get somewhere with sort and uniq commands, but I'm not quite sure what you want. If you have a go at coding yourself, it might become clearer to us.



Kind regards,
Robin
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get the line count from 2nd line of the file ?

Hi, I want to get the line count of the file from the 2nd line of the file ? The first line is header so want to skip that. Thanks. (8 Replies)
Discussion started by: smc3
8 Replies

2. UNIX for Dummies Questions & Answers

find pattern delete line with pattern and line above and line below

I have a file that will sometimes contain a pattern. The pattern is this: W/D FRM CHK 00 I want to find any lines with this pattern, delete those lines, and also delete the line above and the line below. (1 Reply)
Discussion started by: nickg
1 Replies

3. Shell Programming and Scripting

find pattern, delete line with pattern and line above and line below

I have a file that will sometimes contain a pattern. The pattern is this: FRM CHK 0000 I want to find any lines with this pattern, delete those lines, and also delete the line above and the line below. (4 Replies)
Discussion started by: nickg
4 Replies

4. Shell Programming and Scripting

Perl line count if it matches a pattern

#!/usr/bin/perl use Shell; open THEFILE, "C:\galileo_integration.txt" || die "Couldnt open the file!"; @wholeThing = <THEFILE>; close THEFILE; foreach $line (@wholeThing){ if ($line =~ m/\\0$/){ @nextThing = $line; if ($line =~ s/\\0/\\LATEST/g){ @otherThing =... (2 Replies)
Discussion started by: nmattam
2 Replies

5. Shell Programming and Scripting

Shell script to count number of ~ from each line and compare with next line

Hi, I have created one shell script in which it will count number of "~" tilda charactors from each line of the file.But the problem is that i need to count each line count individually, that means. if line one contains 14 "~"s and line two contains 15 "~"s then it should give an error msg.each... (3 Replies)
Discussion started by: Ganesh Khandare
3 Replies

6. Shell Programming and Scripting

Grep the word from pattern line and update in subsequent lines till next pattern line reached

Hi, I have got the below requirement. please suggest. I have a file like, Processing Item is: /data/ing/cfg2/abc.txt /data/ing/cfg3/bgc.txt Processing Item is: /data/cmd/for2/ght.txt /data/kernal/config.klgt.txt I want to process the above file to get the output file like, ... (5 Replies)
Discussion started by: rbalaj16
5 Replies

7. Shell Programming and Scripting

Count number of pattern matches per line for all files in directory

I have a directory of files, each with a variable (though small) number of lines. I would like to go through each line in each file, and print the: -file name -line number -number of matches to the pattern /comp/ for each line. Two example files: cat... (4 Replies)
Discussion started by: pathunkathunk
4 Replies

8. Shell Programming and Scripting

awk to combine lines from line with pattern match to a line that ends in a pattern

I am trying to combine lines with these conditions: 1. First line starts with text of "libname VALUE db2 datasrc" where VALUE can be any text. 2. If condition1 is met then continue to combine lines through a line that ends with a semicolon. 3. Ignore case when matching patterns and remove any... (5 Replies)
Discussion started by: Wes Kem
5 Replies

9. Shell Programming and Scripting

Count the pipes "|" in line and delete line if count greter then number.

Hello, I have been working on Awk/sed one liner which counts the number of occurrences of '|' in pipe separated lines of file and delete the line from files if count exceeds "17". i.e need to get records having exact 17 pipe separated fields(no more or less) currently i have below : awk... (1 Reply)
Discussion started by: ketanraut
1 Replies

10. UNIX for Beginners Questions & Answers

Get an output of lines in pattern 1st line then 10th line then 11th line then 20th line and so on.

Input file: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 (6 Replies)
Discussion started by: Sagar Singh
6 Replies
LEARN(1)						      General Commands Manual							  LEARN(1)

NAME
learn - computer aided instruction about UNIX SYNOPSIS
learn [ -directory ] [ subject [ lesson ] ] DESCRIPTION
Learn gives Computer Aided Instruction courses and practice in the use of UNIX, the C Shell, and the Berkeley text editors. To get started simply type learn. If you had used learn before and left your last session without completing a subject, the program will use information in $HOME/.learnrc to start you up in the same place you left off. Your first time through, learn will ask questions to find out what you want to do. Some questions may be bypassed by naming a subject, and more yet by naming a lesson. You may enter the lesson as a number that learn gave you in a previous session. If you do not know the lesson number, you may enter the lesson as a word, and learn will look for the first lesson containing it. If the lesson is `-', learn prompts for each lesson; this is useful for debugging. The subject's presently handled are files editor vi morefiles macros eqn C There are a few special commands. The command `bye' terminates a learn session and `where' tells you of your progress, with `where m' telling you more. The command `again' re-displays the text of the lesson and `again lesson' lets you review lesson. There is no way for learn to tell you the answers it expects in English, however, the command `hint' prints the last part of the lesson script used to evaluate a response, while `hint m' prints the whole lesson script. This is useful for debugging lessons and might possibly give you an idea about what it expects. The -directory option allows one to exercise a script in a nonstandard place. FILES
/usr/share/learn subtree for all dependent directories and files /usr/tmp/pl* playpen directories $HOME/.learnrc startup information SEE ALSO
csh(1), ex(1) B. W. Kernighan and M. E. Lesk, LEARN - Computer-Aided Instruction on UNIX BUGS
The main strength of learn, that it asks the student to use the real UNIX, also makes possible baffling mistakes. It is helpful, espe- cially for nonprogrammers, to have a UNIX initiate near at hand during the first sessions. Occasionally lessons are incorrect, sometimes because the local version of a command operates in a non-standard way. Occasionally a lesson script does not recognize all the different correct responses, in which case the `hint' command may be useful. Such lessons may be skipped with the `skip' command, but it takes some sophistication to recognize the situation. To find a lesson given as a word, learn does a simple fgrep(1) through the lessons. It is unclear whether this sort of subject indexing is better than none. Spawning a new shell is required for each of many user and internal functions. The `vi' lessons are provided separately from the others. To use them see your system administrator. 7th Edition October 22, 1996 LEARN(1)
All times are GMT -4. The time now is 03:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy