Sponsored Content
Top Forums Shell Programming and Scripting Retreive latest occurrence if there are multiple occurences Post 302266825 by summer_cherry on Thursday 11th of December 2008 05:33:23 AM
Old 12-11-2008
hi,

Below perl should also be ok.

Code:
open FH,"<a.txt";
foreach(<FH>){
	@tmp=split("	",$_);
	$hash{$tmp[0]}=$_;
}
for $key (sort keys %hash){
	print $hash{$key};
}
close FH;

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Trying to retreive and compare value

Hi All, I'm have a file test.txt that looks like this 1939399393 03094994949 948383 I have to check whether the first character in the first line is 1 or not. I have tried the following option but it seems to fail head -1 test.txt | grep ^1 but it seems to display the entire... (3 Replies)
Discussion started by: omahablues
3 Replies

2. 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

3. Shell Programming and Scripting

find the latest files in multiple directory

I want to get the latest files from multiple directories, d1, d2,d3 and d4 under the parent dierectoy d. can anyone help out with this? thx (3 Replies)
Discussion started by: shyork2001
3 Replies

4. Shell Programming and Scripting

last occurrence of a match through multiple files

Hi all, I have a lot of files with extension ".o" and I would like to extract the 10th line after (last) occurrence of a given string in each of the files. I tried: $ grep "string_to_look_for" *.o -A 10 | tail -1 but it gives the occurrence in the last file with extension .o ... (1 Reply)
Discussion started by: f_o_555
1 Replies

5. 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

6. Shell Programming and Scripting

Remove Duplicates on multiple Key Columns and get the Latest Record from Date/Time Column

Hi Experts , we have a CDC file where we need to get the latest record of the Key columns Key Columns will be CDC_FLAG and SRC_PMTN_I and fetch the latest record from the CDC_PRCS_TS Can we do it with a single awk command. Please help.... (3 Replies)
Discussion started by: vijaykodukula
3 Replies

7. Programming

awk to count occurrence of strings and loop for multiple columns

Hi all, If i would like to process a file input as below: col1 col2 col3 ...col100 1 A C E A ... 3 D E G A 5 T T A A 6 D C A G how can i perform a for loop to count the occurences of letters in each column? (just like uniq -c ) in every column. on top of that, i would also like... (8 Replies)
Discussion started by: iling14
8 Replies

8. UNIX for Dummies Questions & Answers

Display latest record from file based on multiple columns combination

I have requirement to print latest record from file based on multiple columns combination. EWAPE EW1SLE0000 EW1SOMU01 ABORTED 03/16/2015 100004 03/16/2015 100005 001 EWAPE EW1SLE0000 EW1SOMU01 ABORTED 03/18/2015 140003 03/18/2015 140004 001 EWAPE EW1SLE0000 EW1SOMU01 ABORTED 03/18/2015 220006... (1 Reply)
Discussion started by: tmalik79
1 Replies

9. Shell Programming and Scripting

Substitute first occurrence of keyword if occurrence between two other keywords

Assume a string that contains one or multiple occurrences of three different keywords (abbreviated as "kw"). I would like to replace kw2 with some other string, say "qux". Specifically, I would like to replace that occurrence of kw2 that is the first one that is preceded by kw1 somewhere in the... (4 Replies)
Discussion started by: M Gruenstaeudl
4 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
WMEMCHR(3)						     Linux Programmer's Manual							WMEMCHR(3)

NAME
wmemchr - search a wide character in a wide-character array SYNOPSIS
#include <wchar.h> wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t n); DESCRIPTION
The wmemchr() function is the wide-character equivalent of the memchr(3) function. It searches the n wide characters starting at s for the first occurrence of the wide character c. RETURN VALUE
The wmemchr() function returns a pointer to the first occurrence of c among the n wide characters starting at s, or NULL if c does not occur among these. ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7). +----------+---------------+---------+ |Interface | Attribute | Value | +----------+---------------+---------+ |wmemchr() | Thread safety | MT-Safe | +----------+---------------+---------+ CONFORMING TO
POSIX.1-2001, POSIX.1-2008, C99. SEE ALSO
memchr(3), wcschr(3) COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. GNU
2015-08-08 WMEMCHR(3)
All times are GMT -4. The time now is 11:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy