(I'm just a newbie in awk & bash scripts) I have a script which replaces one column from an input file with a specified one from the same file. The input and the desired output files are shown below.
The problem is that my script for the moment produce an "incomplete" replacement (see the first column from the third line)
I found on internet some pieces of code which do this with awk and adapted it for my job.
I've modified the first two awks in order to get a supplementary space character, so that the replacement done by awk, would run ok (replace "C " with 3 and "Cu" with 6), but for the moment I still get the incomplete replacement. I think the problem is on the third awk, but I really don't know how to rewrite it.
I have a function
awkvarrep() {
awk -F'|' '$1~/$1/{printf "%-10s %-30s %-15s %-30s %-15s\n", $2,$3,$4,$5,$6}' testfile
}
I'm calling it by this
VARREP=XYZ
awkvarrep $VARREP
since i'm passing $VARREP to the awkvarrep() function I want to use this with $1 but it dosen't seem to be... (5 Replies)
I have an xml file with following tags
<NewTag>value123</xyz>
<NewTag>value321</abcd>
I have to replace the values in between the tags with some value ( VAL1/VAL2)
but the thing the ending tag can be any thing, for this i need a awk command
currently i am using this but it... (5 Replies)
Hey all, Im trying to write a script on windows, which Im not too familiar with. Im generally a bash scripting guy but am using perl for this case.
My question is...
I have this exact output:
2 Dir(s) 6,380,429,312 bytes free
and I just need to get the number out... (4 Replies)
Hi I'm a newbie in unix and I'm having trouble in creating a script. I want to search for a pattern '_good' and insert new lines that contains '_bad', '_med', '_fail' while also ensure that the line contains _good is removed
here some of the data
UPDATE SCHOOL SET GRADE =... (1 Reply)
Hi all,
I need help in replacing awk with sed for the below.
1 ) cat list | awk -F" |," '/MATH/ {sub(/]*/,"",$3); print $3}'
Eg: file : list
Sno Subno Name
1 SUB1 ENG
2 SUB2 MATH
2)
Eg:result
Total No of Students: 2
Sno ID Sub
------------------
1 ... (3 Replies)
hi
i am using awk for first time so i am having issue
is it the correct way of using
Y here is variable which i fetch using grep from file
awk -v X={$Y}
{
if ($0 ~ /X/ ) { sub (out.*/,"out1",$0) }
print 0
}, filename > temp
when i look into temp file i dont see any replacement... (9 Replies)
Hello everyone,
I have a problem with awk replacement... I need to replace "|\n" for "\n"
I tried thisawk '{ sub(/\|\\n/, "\\n"); print }'
but it seems like it doesn't work properly. Can anyone help with that? (4 Replies)
I been trying to figure out how to use element of array as a replacement pattern. This works as I expected:
$ echo "one two three" | awk '{
gsub(/wo/,"_BEG_&_END_",$2);
print }'
one t_BEG_wo_END_ three
$ echo "one two three" | awk '{
tmp="foo";
gsub(/wo/,"_BEG_" tmp "_END_",$2);... (5 Replies)
Hello,
Is it possible to embed the command output to the replacement of sed? Say I need to replace all the blank lines with random strings:
input:
ACCTTCGTCTTCTGG
GCTTGAGATGGTCCA
GCAGGGCTAGTGACG
GACGAGTCTCTTGAC
ACCAAATCAAAGATCand output is:
>26aa36d934d44f06d15b3aab4645a602 $(date |... (9 Replies)
Hi guys,
I worked for almost a half-day for the replacement of some text automatically with script. But no success.
The problem is I have hundred of files, which need to be replaced with some new text. It's a painful work to work manually and it's so easy to do it wrong.
For example,
I... (2 Replies)
Discussion started by: liuzhencc
2 Replies
LEARN ABOUT DEBIAN
igawk
IGAWK(1) Utility Commands IGAWK(1)NAME
igawk - gawk with include files
SYNOPSIS
igawk [ all gawk options ] -f program-file [ -- ] file ...
igawk [ all gawk options ] [ -- ] program-text file ...
DESCRIPTION
Igawk is a simple shell script that adds the ability to have ``include files'' to gawk(1).
AWK programs for igawk are the same as for gawk, except that, in addition, you may have lines like
@include getopt.awk
in your program to include the file getopt.awk from either the current directory or one of the other directories in the search path.
OPTIONS
See gawk(1) for a full description of the AWK language and the options that gawk supports.
EXAMPLES
cat << EOF > test.awk
@include getopt.awk
BEGIN {
while (getopt(ARGC, ARGV, "am:q") != -1)
...
}
EOF
igawk -f test.awk
SEE ALSO gawk(1)
Effective AWK Programming, Edition 1.0, published by the Free Software Foundation, 1995.
AUTHOR
Arnold Robbins (arnold@skeeve.com).
Free Software Foundation Nov 3 1999 IGAWK(1)