find string nth occurrence in file and print line number
Hi
I have requirement to find nth occurrence in a file and capture data from with in lines (between lines)
Data in File.
I want to get the first occurrence of the <SESSION> and </SESSION> and process between lines.
Again capture data from 2nd occurrence of the <SESSION> and </SESSION> until last occurrence repeat the same.
Hi,
I have several files with data that have to be imported to a database. These files contain records with separator characters. Some records are corrupt (2 separators are missing) and I need to correct them prior to importing them into the db.
Example:
... (5 Replies)
I'm trying find and print a number after a specific user passed string in each line of a text file using C (as requested by the powers that be). I've pieced together enough to read the file, find the string and print the line it was found on but I’m not sure where to even start in terms of finding... (3 Replies)
For example i'm having the below contents in a file:
expr is great when you want to split a string into just two parts. The .* also makes expr good for skipping a variable number of words when you don't know how many words a string will have. But expr is lousy for getting, say, the fourth word... (2 Replies)
Greetings experts. Searched the forums (perhaps not hard enough?) - Am searching for a method to capture all output from a log file following the nth occurrence of a known string.
Background:
Using bash, I want to monitor my Oracle DB alert log file. The script will count the total # of... (2 Replies)
if there's a file containing:
money king money queen money cat money also money king
all those strings are on one line in the file.
how can i find out how many times "money king" shows up in the line?
egrep -c "money king" wont work. (7 Replies)
Hello All,
I want to check if a delimiter is existing twice in a line of a text file.
Suppose flat file is like this
234 | 123
123 | 345
456 | 563 |
234 | 548
So the the 3rd line has two delimiters,
How can we find the lines in such a file having more then one delimiters
I tried... (5 Replies)
Bash/Oracle Linux 6.4
A basic requirement.
How can I get nth line of a file printed ? Can I use grep in this case ?
Example:
In the below file, 12th line is "Kernel parameter check passed for rmem_max" . I just want the 12 line to be printed.
# cat sometext.txt
Kernel version check... (2 Replies)
Hi,
I would like to know how, using sed, be able to insert contents of file2 in file1 after say the second occurrence of a given string? e.g.
> cat file1
banana
apple
orange
apple
banana
pear
tangerine
apple
> cat file2
I don't like apples
What would be the sed command to insert... (5 Replies)
Hi
I want to use awk to match where field 3 contains a number within string - then print the line and just the number as a new field.
The source file is pipe delimited and looks something like
1|net|ABC Letr1|1530|||
1|net|EXP_1040 ABC|1121|||
1|net|EXP_TG1224|1122|||
1|net|R_North|1123|||... (5 Replies)
My file (the output of an experiment) starts off looking like this,
_____________________________________________________________
Subjects incorporated to date: 001
Data file started on machine PKSHS260-05CP
**********************************************************************
Subject 1,... (9 Replies)