Search Results

Search: Posts Made By: prabhat.diwaker
10,608
Posted By RavinderSingh13
Hello Prabhat, Please use the following...
Hello Prabhat,

Please use the following code for same.


awk -F"," '{for(i=1;i<=NF;i++){if($i ~ /^\"/ || $i ~ /\"$/) {a=a OFS $i;j++;{if(j%2==0){sub(/^[[:space:]]/,X,a); print a;j=0;a=""}}}...
5,516
Posted By neutronscott
perhaps tr -d '[:cntrl:]' <oldfile >newfile to...
perhaps tr -d '[:cntrl:]' <oldfile >newfile to remove all control codes
5,516
Posted By Corona688
I would expect ^M in Windows .txt files, but the...
I would expect ^M in Windows .txt files, but the ^H, ^@, and so forth are odd. Did these files come from the script utility?
5,516
Posted By neutronscott
ctrl+v is literal insert mode. ^ represents ctrl....
ctrl+v is literal insert mode. ^ represents ctrl. so CTRL+V then CTRL+@ inserts the ^@ (which is a NUL byte)
5,516
Posted By vbe
Well the first thing you should ask yourself is...
Well the first thing you should ask yourself is the origin of the file: is it from a windows/DOS world, then it must be converted to remove the carriage return, either by a dos2ux or dos2unix command...
2,814
Posted By pamu
Then try my solution :)
Then try my solution :)
2,814
Posted By Scrutinizer
You could try something like: awk -F,...
You could try something like:
awk -F, 'NR==FNR{A[$1]=$0; next} {s=x; split(A[$1],F); for (i=2; i<=NF; i++) if($i!=F[i]) s=s (s?FS:x) i; print $1, s}' file2 file1
2,814
Posted By Scrutinizer
You are welcome... I just notice you want to use...
You are welcome... I just notice you want to use $1 as primary key instead of the line number. Then this adaptation would be required:
awk -F, '{s=p=x; getline p<f; n=split(p,F)} n<NF{n=NF} {for...
2,814
Posted By pamu
Try $ awk -F, 'BEGIN{print "record_number ,...
Try

$ awk -F, 'BEGIN{print "record_number , columns_with_diff"}
NR==FNR{for(i=2;i<=NF;i++){A[$1,i]=$i}next}{for(i=2;i<=NF;i++){if($i!=A[$1,i]){p=p?p","i:i}}print $1,p;p=""}' file1 file2...
2,814
Posted By Scrutinizer
Variation without using arrays: awk -F,...
Variation without using arrays:
awk -F, '{s=p=x; getline p<f; split(p,F); for(i=1; i<=NF; i++) if($i!=F[i]) s=s (s?FS:x) i; print NR, s}' f=file2 file1
Showing results 1 to 10 of 10

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