Sponsored Content
Top Forums Shell Programming and Scripting last occurrence of a match through multiple files Post 302480468 by Scrutinizer on Wednesday 15th of December 2010 03:42:03 AM
Old 12-15-2010
Try
Code:
for i in *.o
do
   grep "string_to_look_for" "$i" .....
done

This User Gave Thanks to Scrutinizer For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

last occurrence of a string across multiple files

Hello: Thank you for your help. (2 Replies)
Discussion started by: porphyrin
2 Replies

2. Shell Programming and Scripting

Print last occurrence if first field match

Hi All, I have an input below. If the term in the 1st column is equal, print the last row which 1st column is equal.In the below example, it's " 0001 k= 27 " and " 0004 k= 6 " (depicted in bold). Those terms in 1st column which are not repetitive are to be printed as well. Can any body help me... (9 Replies)
Discussion started by: Raynon
9 Replies

3. Shell Programming and Scripting

SED to replace exact match, not first occurrence.

Lets say I have file.txt: (Product:Price:QuantityAvailable) (: as delimiter) Chocolate:5:5 Banana:33:3 I am doing a edit/update function. I want to change the Quantity Available, so I tried using the SED command to replace 5, but my Price which is also 5 is changed instead. (for the Banana... (13 Replies)
Discussion started by: andylbh
13 Replies

4. Shell Programming and Scripting

sed print from last occurrence match until the end of file

Hi, i have file f1.txt with data like: CHECK a b CHECK c d CHECK e f JOB_START .... I want to match the last occurrence of 'CHECK' until the end of the file. I can use awk: awk '/^CHECK/ { buf = "" } { buf = buf "\n" $0 } END { print buf }' f1.txt | tail +2Is there a cleaner way of... (2 Replies)
Discussion started by: ysrini
2 Replies

5. Shell Programming and Scripting

Match records from multiple files

Hi, I have 3 tab delimited text files which look like this. File1: PROTEINID DESCRIPTION PEPTIDES FRAMES GB://115298678 _gi_115298678_ref_NP_000055.2_ complement C3 precursor 45 55 GB://4502027 _gi_4502027_ref_NP_000468.1_ serum albumin preproprotein 34 73 Entrez://strain 11128 /... (3 Replies)
Discussion started by: Vavad
3 Replies

6. Shell Programming and Scripting

How to count the number of occurrence of words from multiple files?

File 1 aaa bbb ccc File 2 aaa xxx zzz bbb File 3 aaa bbb xxx Output: (4 Replies)
Discussion started by: Misa-Misa
4 Replies

7. UNIX for Dummies Questions & Answers

[Solved] Replace first occurrence after match

hey guys, i have been trying to work this thing out with sed with no luck :confused: i m looking for a way to replace only the first occurrence after a match for example : Cat Realized what you gotta do Dog Realized what you gotta do Sheep Realized what you gotta do Wolf Realized... (6 Replies)
Discussion started by: boaz733
6 Replies

8. Shell Programming and Scripting

Egrep - Only Match First Occurrence

echo 'String#1 and String#2' | egrep -o -m 1 'String#.{1}' String#1 String#2 I'm trying to just match the first occurrence of 'String#' + 1 character. I thought the "-m 1" switch would do that for me. Instead I get both occurrences. Can somebody provide some insight? Thanks! (5 Replies)
Discussion started by: sudo
5 Replies

9. UNIX for Dummies Questions & Answers

Code for exact match to count occurrence

Hi all, I have an input file as below. I would like to count the occurrence of pattern matching 8th field for each line. Input: field_01 field_02 field_03 field_04 field_05 field_06 field_07 field_08 TA T TA T TA TA TA... (3 Replies)
Discussion started by: huiyee1
3 Replies

10. Shell Programming and Scripting

sed print from last occurrence match until the end of last occurrence match

Hi, i have file file.txt with data like: START 03:11:30 a 03:11:40 b END START 03:13:30 eee 03:13:35 fff END jjjjjjjjjjjjjjjjjjjjj START 03:14:30 eee 03:15:30 fff END ggggggggggg iiiiiiiiiiiiiiiiiiiiiiiii I want the below output START (13 Replies)
Discussion started by: Jyotshna
13 Replies
ICONV_STRRPOS(3)							 1							  ICONV_STRRPOS(3)

iconv_strrpos - Finds the last occurrence of a needle within a haystack

SYNOPSIS
int iconv_strrpos (string $haystack, string $needle, [string $charset = ini_get("iconv.internal_encoding")]) DESCRIPTION
Finds the last occurrence of a $needle within a $haystack. In contrast to strrpos(3), the return value of iconv_strrpos(3) is the number of characters that appear before the needle, rather than the offset in bytes to the position where the needle has been found. The characters are counted on the basis of the specified character set $charset. PARAMETERS
o $haystack - The entire string. o $needle - The searched substring. o $charset - If $charset parameter is omitted, $string are assumed to be encoded in iconv.internal_encoding. If $haystack or $needle is not a string, it is converted to a string and applied as the ordinal value of a character. RETURN VALUES
Returns the numeric position of the last occurrence of $needle in $haystack. If $needle is not found, iconv_strrpos(3) will return FALSE. Warning This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE. Please read the section on Booleans for more information. Use the === operator for testing the return value of this function. SEE ALSO
strrpos(3), iconv_strpos(3), mb_strrpos(3). PHP Documentation Group ICONV_STRRPOS(3)
All times are GMT -4. The time now is 10:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy