Sponsored Content
Top Forums Shell Programming and Scripting How to conditionally replace a pattern? Post 302632451 by itkamaraj on Monday 30th of April 2012 07:07:58 AM
Old 04-30-2012
Code:
 
$ nawk '!/static.*return/{if($0!~/return[\; ]/)sub("return","get");print}/static.*return/' test.txt
static int returnint(int num1);
static void returnvoid(int num1);
void main()
{
int num1;
num1=getint(3);
getvoid(2);
getvoid(5);
}
static int returnint(int num1)
{
  getvoid(5);
  return 12;
}
static void returnvoid(int num1)
{
   return;
}

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SED Search Pattern and Replace with the Pattern

Hello All, I have a string "CP_STATUS OSSRC_R6_0_Shipment_R1H_CU AOM_901046 R1H_LLSV1_2008031", and I just want to extract LLSV1, but I dont get the expected result when using the sed command below. # echo "CP_STATUS OSSRC_R6_0_Shipment_R1H_CU AOM_901046 R1H_LLSV1_2008031" | awk '{print... (4 Replies)
Discussion started by: racbern
4 Replies

2. Shell Programming and Scripting

perl:: search for tow pattern and replace the third pattern

Hi i want to search two pattern on same line and replace onther pattern.. INPut file aaaa bbbbb nnnnnn ttttt cccc bbbbb nnnnnn ppppp dddd ccccc nnnnnn ttttt ffff bbbbb oooooo ttttt now i want replace this matrix like.. i want search for "bbbbb","nnnnnn" and search and replace for... (4 Replies)
Discussion started by: nitindreamz
4 Replies

3. Shell Programming and Scripting

How to replace a text in a file conditionally?

I have got about 100 ascii files and I want replace some variable with a new one on an HP-UX system. But I want to put a line of comments before the change. I want to make file1 to file2. I am explaining below. file1: line1 line2 export QNAME=ABC line4 line5 file2: line1 line2 #... (3 Replies)
Discussion started by: asutoshch
3 Replies

4. Shell Programming and Scripting

replace pattern after the first pattern match

I need this. aaa OOOOO bbb ccc OOOOO ddd fff ggg OOOOO iii OOOOO I need all OOOOO replaced with PPPPP, but only change after the pattern ggg. So the first two OOOOO should not be changed. OUTPUT should be :- aaa (2 Replies)
Discussion started by: anilcliff
2 Replies

5. Shell Programming and Scripting

pattern match and replace another pattern in same line

I have a pattern username:x:32005:32006::/usr/local/user:/bin/bash I need to match the line containing username and replace /bin/bash with /usr/local/my/bin/noshell So it becomes username:x:32005:32006::/usr/local/user:/usr/local/my/bin/noshell (7 Replies)
Discussion started by: anilcliff
7 Replies

6. UNIX for Dummies Questions & Answers

How to conditionally replace a pattern?

Hi, How to replace only the function calls with a new name and skip the function definition and declarations. consider the following code. There are 2 functions defined here returnint and returnvoid. I need to replace returnint with giveint and returnvoid with givevoid only in the function... (1 Reply)
Discussion started by: i.srini89
1 Replies

7. Shell Programming and Scripting

Linux: replace pattern with pattern

Hi, I am a rookie of Linux. I have a problem on how can I replace a certain pattern in Linux with nothing. Can anyone help me?:( sample.txt: <binding>App189 ABC SampleMachine1 ABC XXX YYY ZZZ </binding> <binding>App190 ABC SampleMachine2 ABC XXX YYY ZZZ </binding> <binding>App191... (3 Replies)
Discussion started by: dirkaulo
3 Replies

8. Shell Programming and Scripting

Conditionally replace nth argument of every function call

I have very large perl source code file and I want to replace every occurrence function say foo,The function foo has some arguments and I want to replace 2nd argument,the current argument is hex integer and i want to replace it to equivalent string.Also I want to replace function name foo with... (4 Replies)
Discussion started by: pravint
4 Replies

9. Shell Programming and Scripting

sed command to replace two character pattern with another pattern

Not able to paste my content. Please see the attachment :-( (2 Replies)
Discussion started by: vivek d r
2 Replies

10. UNIX for Dummies Questions & Answers

Conditionally replace field content

Hello I am trying to conditionally replace field content in $2 of input file if pattern is found in $4 of the same tab-separated input file. Currently, $2 is empty. I am trying (with no success): awk -F "\t" 'BEGIN {FS="\t"}{ if ($4=="NO") $2=$2"NO"; print $0}' in > out (2 Replies)
Discussion started by: dovah
2 Replies
SoDecimationPercentageElement(3)				       Coin					  SoDecimationPercentageElement(3)

NAME
SoDecimationPercentageElement - The SoDecimationPercentageElement class is yet to be documented. FIXME: write doc. SYNOPSIS
#include <Inventor/elements/SoDecimationPercentageElement.h> Inherits SoFloatElement. Public Member Functions virtual void init (SoState *state) FIXME: write doc. Static Public Member Functions static SoType getClassTypeId (void) static int getClassStackIndex (void) static void * createInstance (void) static void initClass (void) static void set (SoState *const state, SoNode *const node, const float complexity) FIXME: write doc. static void set (SoState *const state, const float complexity) FIXME: write doc. static float get (SoState *const state) FIXME: write doc. static float getDefault (void) FIXME: write doc. Protected Member Functions virtual ~SoDecimationPercentageElement () Additional Inherited Members Detailed Description The SoDecimationPercentageElement class is yet to be documented. FIXME: write doc. Constructor &; Destructor Documentation SoDecimationPercentageElement::~SoDecimationPercentageElement (void) [protected], [virtual] The destructor. Member Function Documentation SoType SoDecimationPercentageElement::getClassTypeId (void) [static] This static method returns the class type. Reimplemented from SoFloatElement. int SoDecimationPercentageElement::getClassStackIndex (void) [static] This static method returns the state stack index for the class. Reimplemented from SoFloatElement. void * SoDecimationPercentageElement::createInstance (void) [static] This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. void SoDecimationPercentageElement::initClass (void) [static] This static method initializes static data for the SoDecimationPercentageElement class. Reimplemented from SoFloatElement. Author Generated automatically by Doxygen for Coin from the source code. Version 3.1.3 Wed May 23 2012 SoDecimationPercentageElement(3)
All times are GMT -4. The time now is 05:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy