Search Results

Search: Posts Made By: Nina2910
1,944
Posted By rohmanovich
Look into expand/unexpand to go between...
Look into expand/unexpand to go between tabs/spaces. And if the number of columns will stay constant, you can just do cat <file> | cut -f1,7-16 (-d is defaulting to tabs).

R
1,944
Posted By Don Cragun
If we go back to your original code: awk 'BEGIN...
If we go back to your original code:
awk 'BEGIN {OFS="\t"}{printf("%s\t",$1)}{for(i=NF-9; i<=NF; i++) {printf("%s\t",$i)};printf "\n" } ' inputfile
I think you will find that the output is tab...
1,944
Posted By RudiC
awk 'BEGIN...
awk 'BEGIN {FS="\t"}{printf("%s\t",$1)}{for(i=NF-9; i<=NF; i++) {printf("%s\t",$i)} printf "\n"} ' file | od -tx1
0000000 4e 41 4d 45 09 37 09 38 09 39 09 31 30 09 31 31
0000020 09 31 32 09 31 33...
1,944
Posted By RudiC
I'd be very surprised if the output were space...
I'd be very surprised if the output were space delimited as you explicitly print the <TAB> char...
Post (or better: attach) your input and output files.
1,944
Posted By RavinderSingh13
Hello Nina2910, Thank you for showing your...
Hello Nina2910,

Thank you for showing your efforts in forum, it will be more good if you could show us the sample Input_file and sample expected output too, could you please try following and do...
3,900
Posted By Don Cragun
Or, if you want a modified version of my...
Or, if you want a modified version of my commented script, you could try:
awk '
BEGIN { # Initialize skip array: S[fn] = char
# If field #3 contains the character specified by char, do NOT check...
3,900
Posted By RudiC
Guessing that you want to flag every non-ignored...
Guessing that you want to flag every non-ignored non-null field, try
awk '
NR == 1 {MX = split (" SEAMPNC", CH, _)
print $0, "NewColumn"
next
}
{SUM = 0
...
3,900
Posted By Don Cragun
Pasting a script that contains tabs into a shell...
Pasting a script that contains tabs into a shell that uses tabs to trigger command completion is not going to work. As Ravinder suggested, copy my script into a file and execute the file.

You...
3,900
Posted By RudiC
Yes:awk ' BEGIN {MX = split (" SEAMPNC",...
Yes:awk '
BEGIN {MX = split (" SEAMPNC", CH, _) # create the CH array : CH[1] = " ",...,CH[7] = "S",...,CH[13] = "C" by splitting a string constant at the empty string...
3,900
Posted By RavinderSingh13
Hello Nina2910, Could you please create a...
Hello Nina2910,

Could you please create a script for example script.ksh, paste script there then give it executable permissions eg-->chmod 755 and then run Rudi's/Don's code, it should fly without...
3,900
Posted By Don Cragun
I agree with RudiC that your specification (in...
I agree with RudiC that your specification (in both post #1 [after 20 edits] and in post #12) saying:

appears to be a mistake. And to get the output you said you want, it would seem that if field...
3,900
Posted By RudiC
If you ignore the heading and start counting from...
If you ignore the heading and start counting from the row after it, row 4 and 6 in my result HAVE "WARNING".
Are you sure that "P" and "N" need to ignore the SAME column (=11)? Or, shouldn't "N"...
3,900
Posted By itkamaraj
#!/bin/bash INPUT_FILE=input.txt awk...
#!/bin/bash

INPUT_FILE=input.txt

awk 'BEGIN{
E_Len=split("7,9,10,11,12,13",E_Arr,",");
}
{
if($3 == "E")
{
for(i=1;i<=E_Len;i++)
{
col_num=E_Arr[i];
sum+=$col_num;
}...
3,900
Posted By RavinderSingh13
Hello Nina2910, Could you please try...
Hello Nina2910,

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

awk 'function sum_check(a,b,c,d,e,f){if(($a+$b+$c+$d+$e+$f)==0){value="Good"} else {value="warning"}} function...
3,900
Posted By Don Cragun
Great. I am glad that you are done updating. ...
Great. I am glad that you are done updating.

Now, please answer all of the questions I asked in post #6 in this thread. And, please give us a clear description of what fields need to be checked...
3,900
Posted By RavinderSingh13
Hello Nina2910, Let's say I have edited your...
Hello Nina2910,

Let's say I have edited your Input_file as follows.

cat Input_file
COLUMN1 COLUMN2 COLUMN3 COLUMN4 COLUMN5 COLUMN6 SMS Email AO Mail Post N Cell
VEGE Potato E W 396 12 0 384 0...
3,900
Posted By RudiC
How about awk ' BEGIN {MX = split (" ...
How about
awk '
BEGIN {MX = split (" SEAMPNC", CH, _)
}
NR > 1 {SUM = 0
for (i = 7; i<=13; i++) if ($3 !~ CH[i]) SUM += $i
$(NF+1) = SUM?"WARNING":"GOOD"
...
3,900
Posted By Don Cragun
You are correct. This is very confusing. You...
You are correct. This is very confusing. You show us code, but do not tell us if it is doing what you want for the single case it seems to try to handle, and for all of the other cases you don't...
3,780
Posted By RavinderSingh13
Hello Nina2910, Above script provided by me...
Hello Nina2910,

Above script provided by me worked fine for me, you could try to run it in as follows too.

cat script.ksh
COUNT=$(ls *.txt | wc -l)
paste *.txt | awk -vcount=$COUNT 'function...
3,780
Posted By RavinderSingh13
Hello Nina2910, So in previous code of...
Hello Nina2910,

So in previous code of mine(POST#4)we need to manually provide number of .txt file into code(where we are using NF/3). So converting code into a script and skipping pain of...
3,780
Posted By RudiC
For any number or order of fields, any order of...
For any number or order of fields, any order of lines, missing fields across files, try
awk '
FNR == 1 {for (n=split($0, T); n>1; n--) if (!(T[n] in HDK)) HDK[T[n]] = ++HDC
...
3,780
Posted By RavinderSingh13
Hello Nina, So number of columns were not...
Hello Nina,

So number of columns were not mentioned before so solution was according to it, so following may help you with dynamic number of columns but condition is Input_files should have same...
3,780
Posted By RavinderSingh13
Hello Nina2910, Welcome to forums, hope you...
Hello Nina2910,

Welcome to forums, hope you will enjoy learning/sharing knowledge here. Could you please try following and let me know how it goes.

awk 'function get(a,b,array1){array1[a]=a in...
Showing results 1 to 23 of 23

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