Search Results

Search: Posts Made By: am24
2,991
Posted By RudiC
Please tryfor (i=2; i<=CNF+2; i++){printf "%7s",...
Please tryfor (i=2; i<=CNF+2; i++){printf "%7s", T[i] > ofn; if(i==18) printf "%7.3f",T[i]=TMP > ofn}
3,265
Posted By RudiC
awk ' FNR == NR {P[NR] = $0 ...
awk '
FNR == NR {P[NR] = $0 # collect to be inserted values from first file into P array
next
}
FNR == 1 {FN++ ...
3,265
Posted By Don Cragun
And here is a commented version of my code: ...
And here is a commented version of my code:
nawk ' # Start nawk script.
# The following section of code is processed when we are reading the 1st input
# file (i.e., when the current number of...
3,265
Posted By Don Cragun
As long as there is one line in 7lines for each...
As long as there is one line in 7lines for each input file, the values in the file 7lines fall in the range -99.999 through 999.999, the value on one line in 7lines is to added between the 18th and...
3,265
Posted By RudiC
If you're very sure there's no empty fields in...
If you're very sure there's no empty fields in your file, try

awk '
FNR == NR {P[NR] = $0
next
}
FNR == 1 {FN++
}
...
3,265
Posted By RudiC
You can't import shell variables into awk the way...
You can't import shell variables into awk the way you do in above post. Please read man awk and/or many threads in here about how to use the -v option to pass variables to awk.

In your case, with...
3,265
Posted By pravin27
You can use getline in awk to get the desire...
You can use getline in awk to get the desire output. i have modified your code as below.
nawk '{print " " $NF}' line2 > nawk6
nawk '
{CNF = (length()-10)/7
...
3,265
Posted By RudiC
You want to insert that value, i.e. it will be...
You want to insert that value, i.e. it will be $19, $19 will become $20, etc.? Then you need to shove every single value one index back. Like for (i=CNF; i>18; i--) $(i+1) = $i.

IF there's NO...
3,265
Posted By pravin27
You can modify your for loop as below. for...
You can modify your for loop as below.
for (i=2; i<=CNF+2; i++) {printf "%7s", T[i]; if ( i == 19) {printf "%7s", "2.979"}}
3,265
Posted By RudiC
Is that one of your fixed field width files...
Is that one of your fixed field width files again? Then you shouldn't say the field separator is space...
Your problem is (man awk: ) Try adapting the method to copy the line into an array, then add...
850
Posted By RudiC
Would this come close to what you need:awk ' ...
Would this come close to what you need:awk '
{CNF = (length()-4)/8
printf "%3s", substr ($0, 1, 3)
for (i=0; i<=CNF; i++) T[i+2] = substr ($0, 4+i*8, 8)

TMP =...
5,934
Posted By RavinderSingh13
Hello am24, BINGO, finally were able to...
Hello am24,

BINGO, finally were able to tackle problem by set -x option which gave the errors of bailing out which shows we should use nawk in place of awk. Now only issue is of space, I could...
5,934
Posted By RavinderSingh13
Hello am24, Could you please try following...
Hello am24,

Could you please try following script, I am just enabling the trace utility here in script, hope set -x option works here. Because I tried this code in bash and it is working fine for...
5,934
Posted By Scrutinizer
This then maybe? I believe it matches your...
This then maybe?

I believe it matches your latest requirements for both Cable Yes && Pay TV && !ADS and Cable Yes && !Pay TV && !ADS IF it is the only thing occurring on a line with for the rest...
5,934
Posted By RavinderSingh13
Hello am24, I have fixed that problem in...
Hello am24,

I have fixed that problem in following code, could you please try following and let me know if this helps you.

awk '{
match($0,/^[[:space:]]+/);
...
5,934
Posted By RavinderSingh13
Hello am24, Still not much clear, on an...
Hello am24,

Still not much clear, on an assumption could you please try following and let me know this helps or not.

awk '{sub(/^[[:space:]]+/,X,$0);num=split("Cable Yes && Pay TV && !ADS",...
5,934
Posted By Don Cragun
Do you see any inconsistency here between your...
Do you see any inconsistency here between your claim that you are running ksh and the output above that clearly shows that you are running csh as your shell?

To change from running csh to actually...
5,934
Posted By Scrutinizer
Hi Ravinder, you appear to have left out "Cable "...
Hi Ravinder, you appear to have left out "Cable " in the output...

It could be shortened a little:
awk -v s1='Cable Yes && !Pay TV && !ADS' '$0==s1 {$0=$0 " && !MDS"}1' Input_file
5,934
Posted By RavinderSingh13
Hello am24, Could you please try this and...
Hello am24,

Could you please try this and let me know if this helps.

awk '{num=split("Cable Yes && !Pay TV && !ADS", array," ");for(i=1;i<=num;i++){if($0 ~ /^Cable/ && array[i]==$i && $0 ~...
5,934
Posted By Scrutinizer
This is due to the bash history expansion...
This is due to the bash history expansion "feature", which can be switched off with set +H
Or you can use single quotes, rather than double quotes, which will protect the exclamation marks from...
5,934
Posted By RavinderSingh13
Hello am24, You should escape the strings as...
Hello am24,

You should escape the strings as \!Pay TV and \!ADS, if you see my post it is exactly provided like as follows.

awk -vs1="Cable Yes && \!Pay TV && \!ADS" '($0 == s1){$0="Yes && !Pay...
5,934
Posted By RavinderSingh13
Hello am24, Could you please try following...
Hello am24,

Could you please try following and let me know if this helps you.

awk -vs1="Cable Yes && \!Pay TV && \!ADS" '($0 == s1){$0="Yes && !Pay TV && !ADS && !MDS"}1' Input_file ...
2,800
Posted By RudiC
Looks like we've been talking past each other;...
Looks like we've been talking past each other; the definition of <TAB> as the input and output field sepatator is responsible for the 0 field at EOL. For fixed widths fields this obviously doesn't...
2,800
Posted By looney
If value of field is not null still you are...
If value of field is not null still you are subtracting filed 2 and field 5.
awk '{ print (NF<6 ? $1" "$2" "$3" "$2-$4" "$4" "$5 : $0)}' file
2,800
Posted By zaxxon
You are mixing up shell and awk command syntax. ...
You are mixing up shell and awk command syntax.

In awk it looks like this:

if( ... ) {
...
}
else {
...
}


There is also superfluous single quotes that will give Problems when...
Showing results 1 to 25 of 44

 
All times are GMT -4. The time now is 11:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy