Sponsored Content
Full Discussion: awk search and replace field
Top Forums Shell Programming and Scripting awk search and replace field Post 302443616 by bluejayek on Monday 9th of August 2010 02:53:26 PM
Old 08-09-2010
Thanks.
That did not entirely work, as in my program it isn't always only numbers inside the pow call, often I'm working with variables as well. However, a very simple change fixed it to work for all cases.
Code:
sed 's/\(.*\)pow(\(.*\),2)\(.*\)/\1\2\*\2\3/' a1

I replaced the [0-9] in yours with a . to match any pattern.

Thanks again, I didn't really know how to work the \ \ fields to output what I wanted.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl - search and replace a particular field

Hi, I have a file having around 30 records. Each record has 5 fields delimited by PIPE. Few records in the file having Junk characters in the field2 and field4. I found the junk charcter and I tested it and replace the junk with space with the command below perl -i -p -e "s/\x00/ /g"... (1 Reply)
Discussion started by: ramkrix
1 Replies

2. Shell Programming and Scripting

Awk Search text string in field, not all in field.

Hello, I am using awk to match text in a tab separated field and am able to do so when matching the exact word. My problem is that I would like to match any sequence of text in the tab-separated field without having to match it all. Any help will be appreciated. Please see the code below. awk... (3 Replies)
Discussion started by: rocket_dog
3 Replies

3. Shell Programming and Scripting

Search duplicate field and replace one of them with new value

Dear All, I have file with 4 columns: 1 AA 0 21 2 BB 0 31 3 AA 0 21 4 CC 0 41 I would like to find the duplicate record based on column 2 and replace the 4th column of the duplicate by a new value. So, the output will be: 1 AA 0 21 2 BB 0 31 3 AA 0 -21 4 CC 0 41 Any suggestions... (3 Replies)
Discussion started by: ezhil01
3 Replies

4. Shell Programming and Scripting

Search a string,get line and replace with second field

Hi, I need to search for source path in file2 , as per file1 and if found get the next line and take the field value and put it in URL value of file1. In file1, NF is not same for all the lines. file1: <type source="/home/USER/Desktop" Dest="/home/USER/DIR1/Desktop" URL="ssh/path"/> <type... (8 Replies)
Discussion started by: greet_sed
8 Replies

5. Shell Programming and Scripting

Search and replace field?

I have 2 files A.txt and B.txt A.txt 3 fields and separate by a comma some,thing,florida any1,thing1,california some2,thing2,dallas just,fun,kansas B.txt has 8 fields and separate by a comma what,ever,florida-state,,,,,, some,one,dallas_state,,,,,, You will see 3rd fields are the... (5 Replies)
Discussion started by: sabercats
5 Replies

6. Shell Programming and Scripting

awk search/replace specific field, using variables for regexp & subsitution then overwrite file

Hello, I'm trying the solve the following problem. I have a file which I intend to use as a csv called master.csv The columns are separated by commas. I want to change the text on a specific row in either column 3,4,5 or 6 from xxx to yyy depending upon if column 1 matches a specified pattern.... (3 Replies)
Discussion started by: cyphex
3 Replies

7. Shell Programming and Scripting

awk search and replace in a targeted field instead of $0

Hi I would like to apply this gawk command: gawk '{$0=gensub(/\y+\y/,"","g"); print}' file not to the whole $0 but just to the part of $0 that is between: (a number)"> and </mrk> Is it possible? thanks for your help. (4 Replies)
Discussion started by: louisJ
4 Replies

8. UNIX for Dummies Questions & Answers

Shell script for search and replace by field

Hi, I have an input file with below data and rules file to apply search and replace by each field in the input based on exact value or pattern. Could you please help me with unix script to read input file and rules file and then create the output and reject files based on the rules file. Input... (13 Replies)
Discussion started by: chandrath
13 Replies

9. Shell Programming and Scripting

Search for a value and replace other field in the same set

Hello friends, I have huge file with many sets where each "set" has few lines and each set always begins with "Set" in Sq brackets as shown above. # cat file1 (2 Replies)
Discussion started by: magnus29
2 Replies

10. UNIX for Dummies Questions & Answers

Search and replace the last field

Hi All, Seeking for your assistance on how to search and replace the last field/column. please see sample below: inputfile1.csv ="8923523434",="543623534"="afd23535623",="100"="200" ="8923523431",="543623536"="afd23535626",="101"="201"... (3 Replies)
Discussion started by: poginiks
3 Replies
pow(3M) 						  Mathematical Library Functions						   pow(3M)

NAME
pow, powf, powl - power function SYNOPSIS
cc [ flag... ] file... -lm [ library... ] #include <math.h> double pow(double x, double y); float powf(float x, float y); long double powl(long double x, long double y); DESCRIPTION
These functions compute the value of x raised to the power y, x**y. If x is negative, y must be an integer value. RETURN VALUES
Upon successful completion, these functions return the value of x raised to the power y. For finite values of x < 0, and finite non-integer values of y, a domain error occurs and either a NaN (if representable), or an implemen- tation-defined value shall be returned. If the correct value would cause overflow, a range error occurs and pow(), powf(), and powl() return HUGE_VAL, HUGE_VALF, and HUGE_VALL, respectively. If x or y is a NaN, a NaN is returned unless: o For any finite value of y, if x is +1 and y is either +-Inf or NaN and the application is SUSv3-conforming (see standards(5)), 1.0 is returned. o For any value of x (including NaN), if y is +-0, 1.0 is returned. For any odd integer value of y > 0, if x is +-0, +-0 is returned. For y > 0 and not an odd integer, if x is +-0, +0 is returned. If x is -1, and y is +-Inf, 1.0 is returned. For |x| < 1, if y is -Inf, +Inf is returned. For |x| > 1, if y is -Inf, +0 is returned. For |x| < 1, if y is +Inf, +0 is returned. For |x| > 1, if y is +Inf, +Inf is returned. For y an odd integer < 0, if x is -Inf, -0 is returned. For y < 0 and not an odd integer, if x is -Inf, +0 is returned. For y an odd integer > 0, if x is -Inf, -Inf is returned. For y > 0 and not an odd integer, if x is -Inf, +Inf is returned. For y < 0, if x is +Inf, +0 is returned. For y > 0, if x is +Inf, +Inf is returned. For y an odd integer < 0, if x is +-0, a pole error occurs and +-HUGE_VAL, +-HUGE_VALF, and +-HUGE_VALL are returned for pow(), powf(), and powl(), respectively. For y < 0 and not an odd integer, if x is +-0, a pole error occurs and HUGE_VAL, HUGE_VALF, and HUGE_VALL are returned for pow(), powf(), and powl(), respectively. For exceptional cases, matherr(3M) tabulates the values to be returned by pow() as specified by SVID3 and XPG3. ERRORS
These functions will fail if: Domain Error The value of x is negative and y is a finite non-integer. If the integer expression (math_errhandling & MATH_ERREXCEPT) is non-zero, the invalid floating-point exception is raised. The pow() function sets errno to EDOM if the value of x is negative and y is non-integral. Pole Error The value of x is 0 and y is negative. If the integer expression (math_errhandling & MATH_ERREXCEPT) is non-zero, the divide-by-zero floating-point exception is raised. Range Error The result overflows. If the integer expression (math_errhandling & MATH_ERREXCEPT) is non-zero, the overflow floating-point exception is raised. The pow() function sets errno to EDOM if the value to be returned would cause overflow. USAGE
An application wanting to check for exceptions should call feclearexcept(FE_ALL_EXCEPT) before calling these functions. On return, if fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an exception has been raised. An application should either examine the return value or check the floating point exception flags to detect exceptions. An application can also set errno to 0 before calling pow(). On return, if errno is non-zero, an error has occurred. The powf() and powl() functions do not set errno. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
exp(3M), feclearexcept(3M), fetestexcept(3M), isnan(3M), math.h(3HEAD), matherr(3M), attributes(5), standards(5) NOTES
Prior to Solaris 2.6, there was a conflict between the pow function in this library and the pow function in the libmp library. This con- flict was resolved by prepending mp_ to all functions in the libmp library. See mp(3MP) for details. SunOS 5.10 1 Nov 2003 pow(3M)
All times are GMT -4. The time now is 03:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy