Sponsored Content
Top Forums Shell Programming and Scripting find the first instance after a string Post 302317526 by josslate on Tuesday 19th of May 2009 08:11:17 AM
Old 05-19-2009
Superb - thanks devtakh, that works a treat.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

replace nth instance of string

Hi all, I have file with following content ........................... ..........TEST.......... ..........TEST.......... ..................... .....TEST.......... ..................... ..................... .....TEST.......... I want to replace nth "TEST" with "OK" using... (4 Replies)
Discussion started by: uttamhoode
4 Replies

2. UNIX for Dummies Questions & Answers

Find first instance of pattern

I am using grep to find header info in a file and print it to another file. The header info only shows up on line 3 and 4 so i really don't need to search the remainder of the file. the grep -m option doesn't work with my version of UNIX. Also I'm new to UNIX so could you please explain what... (4 Replies)
Discussion started by: NobluesFDT
4 Replies

3. Shell Programming and Scripting

Search the last instance of a string in a file

I have a big database log file which keepsgrowing daily. OS is HP UX. Here is a small part of it: Tue Jan 27 04:03:22 2009 : add session begin for mfgeb on /dev/pts/th. : Converting relative path to absolute path. : add session end. Tue Jan 27 04:03:29... (6 Replies)
Discussion started by: dinesh1178
6 Replies

4. UNIX for Dummies Questions & Answers

replacing a particular instance in a string globally

Hi, I'm trying to update the last two characters coming in a string globally in a file. Here is the sample data: file1 In file1, I want to have all instances replace where _o is appearing in the end of a word with _g. If _o is appearing in the middle or any other position except the... (2 Replies)
Discussion started by: er_ashu
2 Replies

5. Shell Programming and Scripting

awk - find first instance of string after NR==10

How do I use awk to find the NR of first instance of a specific string after eg NR==10? I need to find the first instance of the word "class" after a specific NR. (2 Replies)
Discussion started by: locoroco
2 Replies

6. Shell Programming and Scripting

awk - last instance of a string

How do I use awk to find the last occurence of a string in a file? (3 Replies)
Discussion started by: locoroco
3 Replies

7. Shell Programming and Scripting

Search text file, then grep next instance of string

I need to be able to search for a beginning line header, then use grep or something else to get the very next instance of a particular string, which will ALWAYS be in "Line5". What I have is some data that appears like this: Line1 Line2 Line3 Line4 Line5 Line6 Line7 Line1 Line2 ...... (4 Replies)
Discussion started by: Akilleez
4 Replies

8. Shell Programming and Scripting

grep second instance of same string

Hi all, i am new to unix scripting in ksh or any shell for that matter. I have downloaded a xml file from a website and saved on my local harddrive. inside the xml, the same tag is listed multiple times. <title>Tonight</title> <title>Thursday</title> <title>Friday</title>... (6 Replies)
Discussion started by: scubasteve39
6 Replies

9. Shell Programming and Scripting

Complex find and replace only 1st instance string with dynamic combination

test.txt is the dynamic file but some of combination are fix like below are the lines ;wonder_off = ;wonder_off = disabled wonder_off = wonder_off = disabled the test.txt can content them in any order #cat test.xt ;wonder_off = ;wonder_off = disabled wonder_off = wonder_off =... (5 Replies)
Discussion started by: SilvesterJ
5 Replies

10. Shell Programming and Scripting

grep for a string until instance of a space

Hey guys, I'm having a bit of trouble getting this to work using either sed or grep. It's possible awk might be the ticket I need as well, but my regulat expression skills aren't quite up to the task for doing this. I'm looking to grep for the string ERROR from the following log up until any... (6 Replies)
Discussion started by: terrell
6 Replies
FMTMSG(3)						   BSD Library Functions Manual 						 FMTMSG(3)

NAME
fmtmsg -- display a detailed diagnostic message LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <fmtmsg.h> int fmtmsg(long classification, const char *label, int severity, const char *text, const char *action, const char *tag); DESCRIPTION
The fmtmsg() function displays a detailed diagnostic message, based on the supplied arguments, to stderr and/or the system console. The classification argument is the bitwise inclusive OR of zero or one of the manifest constants from each of the classification groups below. The Output classification group is an exception since both MM_PRINT and MM_CONSOLE may be specified. Output MM_PRINT Output should take place on stderr. MM_CONSOLE Output should take place on the system console. Source of Condition (Major) MM_HARD The source of the condition is hardware related. MM_SOFT The source of the condition is software related. MM_FIRM The source of the condition is firmware related. Source of Condition (Minor) MM_APPL The condition was detected at the application level. MM_UTIL The condition was detected at the utility level. MM_OPSYS The condition was detected at the operating system level. Status MM_RECOVER The application can recover from the condition. MM_NRECOV The application is unable to recover from the condition. Alternatively, the MM_NULLMC manifest constant may be used to specify no classification. The label argument indicates the source of the message. It is made up of two fields separated by a colon (':'). The first field can be up to 10 bytes, and the second field can be up to 14 bytes. The MM_NULLLBL manifest constant may be used to specify no label. The severity argument identifies the importance of the condition. One of the following manifest constants should be used for this argument. MM_HALT The application has confronted a serious fault and is halting. MM_ERROR The application has detected a fault. MM_WARNING The application has detected an unusual condition, that could be indicative of a problem. MM_INFO The application is providing information about a non-error condition. MM_NOSEV No severity level supplied. The text argument details the error condition that caused the message. There is no limit on the size of this character string. The MM_NULLTXT manifest constant may be used to specify no text. The action argument details how the error-recovery process should begin. Upon output, fmtmsg() will prefix "TO FIX:" to the beginning of the action argument. The MM_NULLACT manifest constant may be used to specify no action. The tag argument should reference online documentation for the message. This usually includes the label and a unique identifying number. An example tag is "BSD:ls:168". The MM_NULLTAG manifest constant may be used to specify no tag. RETURN VALUES
The fmtmsg() function returns MM_OK upon success, MM_NOMSG to indicate output to stderr failed, MM_NOCON to indicate output to the system console failed, or MM_NOTOK to indicate output to stderr and the system console failed. ENVIRONMENT
The MSGVERB (message verbosity) environment variable specifies which arguments to fmtmsg() will be output to stderr, and in which order. MSGVERB should be a colon (':') separated list of identifiers. Valid identifiers include: label, severity, text, action, and tag. If invalid identifiers are specified or incorrectly separated, the default message verbosity and ordering will be used. The default ordering is equivalent to a MSGVERB with a value of "label:severity:text:action:tag". EXAMPLES
The code: fmtmsg(MM_UTIL | MM_PRINT, "BSD:ls", MM_ERROR, "illegal option -- z", "refer to manual", "BSD:ls:001"); will output: BSD:ls: ERROR: illegal option -- z TO FIX: refer to manual BSD:ls:001 to stderr. The same code, with MSGVERB set to "text:severity:action:tag", produces: illegal option -- z: ERROR TO FIX: refer to manual BSD:ls:001 SEE ALSO
err(3), exit(3), strerror(3) STANDARDS
The fmtmsg() function conforms to IEEE Std 1003.1-2001 (``POSIX.1''). HISTORY
The fmtmsg() function first appeared in FreeBSD 5.0. BUGS
Specifying MM_NULLMC for the classification argument makes little sense, since without an output specified, fmtmsg() is unable to do anything useful. In order for fmtmsg() to output to the system console, the effective user must have appropriate permission to write to /dev/console. This means that on most systems fmtmsg() will return MM_NOCON unless the effective user is root. BSD
August 5, 2002 BSD
All times are GMT -4. The time now is 08:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy