Not sure what's going on it is working fine for me, could you please try following things.
I- Check if there are any carriage characters are present or not in your Input_file by doing cat -v Input_file. If yes then remove them by adding gsub(/\r/,"") in starting of my previous post's solution.
II- If no carriage characters, then ,my second guess would be are you using Sun OS/Solaris? If yes then, on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk , /usr/xpg6/bin/awk , or nawk .
Let me know how it goes then.
Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
Thanks R.Singh. It did not work.
Is there any other way we can do this by reading the input file first --
something like --
.
Thanks
Hello Indra2011,
awk could read any Input_file by its own no need to use cat here.
You have to show us the complete console output like what's going on there, without that we could only guess.
Also I am coming with this function approach for this question, where you could just mention like how many columns you want to verify.
Following is the code on same too:
1st Scenario: with your asked query. 2nd scenario: Input_file which I have created for checking purposes, a test file
In this above code I have provided 1,2,3,4 fields so it will look for 1st, 2nd, 3rd and 4th fields here. Kindly do check the same and let me know if you have any queries.
EDIT: Adding a NON-one liner form of solution too successfully now. EDIT2: In above code you could change from !$array[i] to $array[i] == "" in case your Input_file may have zero too in any of the columns.
Thanks,
R. Singh
Last edited by RavinderSingh13; 06-05-2017 at 05:33 PM..
Reason: Adding a NON-one liner form of solution too successfully now.
Did any of the proposals given in this thread run error free? If yes, what did you change in post#7? If no, please post your command and its stdin and stderr output exactly as is, one to one, char by char, so we have a chance to analyse.
Hi Ravinder,
Many many thanks for help. This was what I get while running the code.
[CODE]disco,mum $ awk '!$1{$1=OLD1} !$2{$2=OLD2} !$3{$3=OLD3} {OLD1=$1; OLD2=$2; OLD3=$3} 1' FS="," OFS="," test
awk 'test1{$1=OLD1} test2{$2=OLD2} test3{$3=OLD3} {OLD1=$1; OLD2=$2; OLD3=$3} 1' FS="," OFS="," test
Thanks
Hello Indra2011,
I haven't seen your second command in any of the solutions provided in this thread?
It will NOT give any results as variables named test1, test2, test3 are never having values.
Could you please try my code(s) in POST#10 and let us know how it goes then?
Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post: