Sponsored Content
Full Discussion: awk search and replace field
Top Forums Shell Programming and Scripting awk search and replace field Post 302443609 by guruprasadpr on Monday 9th of August 2010 02:17:30 PM
Old 08-09-2010
Hi
If I had understood you correctly:
Assuming a1 is your input file.
Code:
# cat a1
Kitten pow(3,2) bc
Dogs pow(4,2) adf
Donkey werwe
Chicken  pow(5,2) efg
Turkey werw
#
# sed 's/\(.*\)pow(\([0-9]*\),2)\(.*\)/\1\2\*\2\3/' a1
Kitten 3*3 bc
Dogs 4*4 adf
Donkey werwe
Chicken  5*5 efg
Turkey werw
#

This User Gave Thanks to guruprasadpr For This Post:
 

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(3)							   BSD Library Functions Manual 						    POW(3)

NAME
pow -- power function SYNOPSIS
#include <math.h> double pow(double x, double y); long double powl(long double x, long double y); float powf(float x, float y); DESCRIPTION
The pow() functions compute x raised to the power y. SPECIAL VALUES
pow(+-0, y) returns +-infinity and raises the "divide-by-zero" floating-point exception for y an odd integer < 0. pow(+-0, y) returns +infinity and raises the "divide-by-zero" floating-point exception for y < 0 and not an odd integer. pow(+-0, y) returns +-0 for y an odd integer > 0. pow(+-0, y) returns +0 for y > 0 and not an odd integer. pow(-1, +-infinity) returns 1. pow(1, y) returns 1 for any y, even a NaN. pow(x, +-0) returns 1 for any x, even a NaN. pow(x, y) returns a NaN and raises the "invalid" floating-point exception for finite x < 0 and finite non-integer y. pow(x, -infinity) returns +infinity for |x| < 1. pow(x, -infinity) returns +0 for |x| > 1. pow(x, +infinity) returns +0 for |x| < 1. pow(x, +infinity) returns +infinity for |x| > 1. pow(-infinity, y) returns -0 for y an odd integer < 0. pow(-infinity, y) returns +0 for y < 0 and not an odd integer. pow(-infinity, y) returns -infinity for y an odd integer > 0. pow(-infinity, y) returns +infinity for y > 0 and not an odd integer. pow(+infinity, y) returns +0 for y < 0. pow(+infinity, y) returns +infinity for y > 0. A domain error occurs if x is finite and negative and y is finite and not an integer. A domain error can occur if x is 0 and y less than or equal to 0. Range errors may occur. VECTOR OPERATIONS
If you need to apply the pow() functions to SIMD vectors or arrays, using the following functions provided by the Accelerate.framework may give significantly better performance: #include <Accelerate/Accelerate.h> vFloat vpowf(vFloat x, vFloat y); vFloat vpowf(vFloat x, vSInt32 y); void vvpowf(float *z, const float *y, const float *x, const int *n); void vvpow(double *z, const double *y, const double *x, const int *n); void vvpowsf(float *z, const float *y, const float *x, const int *n); void vvpows(double *z, const double *y, const double *x, const int *n); SEE ALSO
exp(3) math(3) STANDARDS
The pow() function conforms to ISO/IEC 9899:2011. 4th Berkeley Distribution December 11, 2006 4th Berkeley Distribution
All times are GMT -4. The time now is 10:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy