Sponsored Content
Top Forums Shell Programming and Scripting Print last occurrence if first field match Post 302145997 by Raynon on Friday 16th of November 2007 03:07:38 AM
Old 11-16-2007
Hi vgersh99,

Can i use " NR " instead of " FNR " for this case this there's only one input file ?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to Match first field of two Files and print

Hi, I want to get script or command in Sun Unix which matches first fields of both the files and print the feilds of one files, example may make it more clear. InputFile1 ================== Alex,1,fgh Menthos,45454,toto Gothica,855,ee Zenie4,77,gg Salvatore,66,oo Dhin,1234,papapa... (3 Replies)
Discussion started by: indian.ace
3 Replies

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

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

4. UNIX for Dummies Questions & Answers

Match pattern in a field, print pattern only instead of the entire field

Hi ! I have a tab-delimited file, file.tab: Column1 Column2 Column3 aaaaaaaaaa bbtomatoesbbbbbb cccccccccc ddddddddd eeeeappleseeeeeeeee ffffffffffffff ggggggggg hhhhhhtomatoeshhh iiiiiiiiiiiiiiii ... (18 Replies)
Discussion started by: lucasvs
18 Replies

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

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

7. Shell Programming and Scripting

Match columns and print specific field

Hello, I have data in following format. ... (6 Replies)
Discussion started by: Pushpraj
6 Replies

8. Shell Programming and Scripting

Command/script to match a field and print the next field of each line in a file.

Hello, I have a text file in the below format: Source Destination State Lag Status CQA02W2K12pl:D:\CAQA ... (10 Replies)
Discussion started by: pocodot
10 Replies

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

10. Shell Programming and Scripting

awk to print text in field if match and range is met

In the awk below I am trying to match the value in $4 of file1 with the split value from $4 in file2. I store the value of $4 in file1 in A and the split value (using the _ for the split) in array. I then strore the value in $2 as min, the value in $3 as max, and the value in $1 as chr. If A is... (6 Replies)
Discussion started by: cmccabe
6 Replies
ICONV(3)						     Linux Programmer's Manual							  ICONV(3)

NAME
iconv - perform character set conversion SYNOPSIS
#include <iconv.h> size_t iconv(iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft); DESCRIPTION
The argument cd must be a conversion descriptor created using the function iconv_open. The main case is when inbuf is not NULL and *inbuf is not NULL. In this case, the iconv function converts the multibyte sequence starting at *inbuf to a multibyte sequence starting at *outbuf. At most *inbytesleft bytes, starting at *inbuf, will be read. At most *out- bytesleft bytes, starting at *outbuf, will be written. The iconv function converts one multibyte character at a time, and for each character conversion it increments *inbuf and decrements *inbytesleft by the number of converted input bytes, it increments *outbuf and decrements *outbytesleft by the number of converted output bytes, and it updates the conversion state contained in cd. The conversion can stop for four reasons: 1. An invalid multibyte sequence is encountered in the input. In this case it sets errno to EILSEQ and returns (size_t)(-1). *inbuf is left pointing to the beginning of the invalid multibyte sequence. 2. The input byte sequence has been entirely converted, i.e. *inbytesleft has gone down to 0. In this case iconv returns the number of non- reversible conversions performed during this call. 3. An incomplete multibyte sequence is encountered in the input, and the input byte sequence terminates after it. In this case it sets errno to EINVAL and returns (size_t)(-1). *inbuf is left pointing to the beginning of the incomplete multibyte sequence. 4. The output buffer has no more room for the next converted character. In this case it sets errno to E2BIG and returns (size_t)(-1). A different case is when inbuf is NULL or *inbuf is NULL, but outbuf is not NULL and *outbuf is not NULL. In this case, the iconv function attempts to set cd's conversion state to the initial state and store a corresponding shift sequence at *outbuf. At most *outbytesleft bytes, starting at *outbuf, will be written. If the output buffer has no more room for this reset sequence, it sets errno to E2BIG and returns (size_t)(-1). Otherwise it increments *outbuf and decrements *outbytesleft by the number of bytes written. A third case is when inbuf is NULL or *inbuf is NULL, and outbuf is NULL or *outbuf is NULL. In this case, the iconv function sets cd's conversion state to the initial state. RETURN VALUE
The iconv function returns the number of characters converted in a non-reversible way during this call; reversible conversions are not counted. In case of error, it sets errno and returns (size_t)(-1). ERRORS
The following errors can occur, among others: E2BIG There is not sufficient room at *outbuf. EILSEQ An invalid multibyte sequence has been encountered in the input. EINVAL An incomplete multibyte sequence has been encountered in the input. CONFORMING TO
UNIX98 SEE ALSO
iconv_open(3), iconv_close(3) GNU
2001-11-15 ICONV(3)
All times are GMT -4. The time now is 11:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy