AWK How to replace a field using 2 shell variables?
Hello everybody:
I want to replace any field $2 of any file line (f.i. test.txt) matching $1 with a shell variable.
Now I'm going to ask the value of variable B:
And finally i tries to replace this value ("A") from field 2 by another shell variable with "10", using awk again:
Unfortunately I only gets fatal error messages again & again.
Can you help me, please?
Thanks all in advace.
Hi,
I have been trying to use awk with variables that needs to search for a pattern and replace it with another pattern, the patterns are supplied in a variable. I have tried several different ways without success and hope that someone can help me. Here are the details
echo $UPC
07007457809... (2 Replies)
i have bad data for instance, the use of capital letters in the middle of the word.
I identified the errors, made a list and put it in a file error_correction.txt
Incorrect,Correct
VeNOM,Venom
nos,NOS
.
.
.
My data file looks like this:
vgr,bugatti veron,,3.5,Venom,6,.......,....... (14 Replies)
Hi
I am using awk to replace the 4th feild of the input line. My code is below:
REP_LINE=$(echo $Line | awk -v var=$REPL_DT '{$4=var; print}')
It does replaces but all words/phrases after the 4th feild are erased. Is there a way to modify the 4th feild of the input line and to have all... (7 Replies)
I am writing a c++ program that has many calls of pow(input,2). I now realize that this is slowing down the program and these all should be input * input for greater speed.
There should be a simple way of doing this replacement throughout my file with awk, but I am not very familiar with awk.... (2 Replies)
I need to replace specific field (x) in a table with new value (y):
Input:
1 2 3 4
5 x 6 7
8 9 0 0
Output:
1 2 3 4
5 y 6 7
8 9 0 0
I have no idea how to do this. (10 Replies)
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)
I have some problem with this.
Need to change field #3 to 5 if field #1 = A and filed #2 =B
DataA C 6 T
C B 4 R
A B 3 T
D E 5 4
I would like to do two things if statement is true, but can not get it to work.
Here it prints column #3 if statement is true, and this works
awk '{if... (3 Replies)
Hi Friends,
I have looked around the forums and over online but couldn't figure out how to deal with this problem
input.txt
gene1,axis1/0/1,axis2/0/1
gene1,axis1/1/2,axis2/1/2
gene1,axis1/2/3,axis2/2/3
gene2,axis1/3/4,axis2/3/4
Match on first column and if first column is... (1 Reply)
Hi,
I have a file like below
PRUM,67016800 ,CC ,C1,67016800 , ,Y,Y,2 ,CK,BX,FOX ,00000001,EA,00000001,20141120 00:00:00, ,N,Y,Y,CK ABCDEF... (7 Replies)
I have been reading old posts and trying to come up with a solution for the below: Use a tab-delimited input file to assign
point to variables that are used to update a specific field, Rank. I really couldn't find too much in the way of assigning points
to variable, but made an attempt at an awk... (4 Replies)