Search Results

Search: Posts Made By: arunkumar_mca
879
Posted By vgersh99
awk -F'[;]' '{ t[$1 OFS $2]+=$3 } END { for (i in...
awk -F'[;]' '{ t[$1 OFS $2]+=$3 } END { for (i in t) print i, t[i] }' myFile
For the 'Also' part... please post sample representative input.
879
Posted By Yoda
Your data appears to have variable number of...
Your data appears to have variable number of columns. The code you wrote will work if all rows in your input file has exactly three columns.

But if that is how your input data is, then one...
879
Posted By Scrutinizer
I tried the second one and it works, but your...
I tried the second one and it works, but your input file seems to broken. Try it with this one:
10264;ATE;12
10265;SES;11
10266;AUT;50
10264;ATE;10
10265;SES;13
10266;AUT;89
10264;ATE;1...
1,220
Posted By RudiC
Try join -t";" -a1 -a2 -eNA -oauto...
Try
join -t";" -a1 -a2 -eNA -oauto file[12]
1,188
Posted By RudiC
Try also awk ' {print substr($0,1,8)...
Try also
awk '
{print substr($0,1,8) substr (sprintf ("%d", substr($0, 9, 6) "000"), 1, 6) substr($0,15)
}
' file
1,188
Posted By RavinderSingh13
Hello arunkumar_mca, Could you please try...
Hello arunkumar_mca,

Could you please try following once.


awk '{val1=substr($0,9,6);val2=val1+0<10000?sprintf("%06d",val1*1000):val1;print substr($0,1,8) val2 substr($0,15)}' Input_file

...
1,210
Posted By Scrutinizer
Hi, try: awk ' { ...
Hi, try:
awk '
{
result=substr($0,50,5) * substr($0,55,6) * substr($0,88,3) * substr($0,81,7) / 10^8
tot+=result
print result
}
END {
print tot
}
' file

In GNU...
1,210
Posted By RudiC
Why not use awk for the arithmetics as well?
Why not use awk for the arithmetics as well?
149
Posted By stomp
cut cut -c1-35,42- data.txt sed sed...
cut

cut -c1-35,42- data.txt

sed
sed -re 's/(.{35}).{6}/\1/' data.txt

Perl

perl -pe 's/^(.{35}).{6}/$1/' data.txt

GNU(!) awk

awk 'match($0,/^(.{35}).{6}(.*)/,res){print res[1]...
230
Posted By Don Cragun
Note that the code RavinderSingh13 suggested in...
Note that the code RavinderSingh13 suggested in post #2 in this thread will change the 35th character on every line; not just on lines where the original character in that position was "8".

For...
162
Posted By nezabudka
grep -f <(sed 's/.*/^&/' file2) file1
grep -f <(sed 's/.*/^&/' file2) file1
162
Posted By Corona688
You're not comparing the same thing, try awk...
You're not comparing the same thing, try
awk 'NR==FNR{a[substr($0,1,8)];next} (substr($2,1,8) in a)' file2 file1
162
Posted By Corona688
You're giving it file_1 first, which isn't the...
You're giving it file_1 first, which isn't the file containing the keys to match with, and later, matching against column 1 of the other wrong file.

So, let's try saving the keys from file_2, then...
191
Posted By MadeInGermany
bash and ksh can do process substitution: diff...
bash and ksh can do process substitution:
diff <(cut -f1 -d. file1) <(cut -f1 -d. file2)
Everything after a dot is cut off, before it's handed to diff.
Or more general, cut decimals from *all*...
191
Posted By RavinderSingh13
Hello arunkumar_mca, Good that you have...
Hello arunkumar_mca,

Good that you have posted and informed us that you have found the solution. I would like to suggest you that in these cases you could do 2 things.

1st: Add "solved" TAG in...
540
Posted By Peasant
Is the above a mistake, since you posted...
Is the above a mistake, since you posted subtraction bigger then 5 or 6 and above is 16 ?

Well you really gave me a challenge for one who doesn't code like this on a daily basis :D
This is surely...
540
Posted By Peasant
All the subtraction done on fields ($2,$10)...
All the subtraction done on fields ($2,$10) depends on year on field $4, the variance defined.
If no input on $2 matches string PP<number>, $2 is printed as is, unchanged.
If no input on $10...
540
Posted By Peasant
Fixed some typos..
I'm not sure i follow.
Input now is also inconsistent, with first two rows having 13 fields and last having 12.

Now you say you require fields 2,4 and 10, but on expected output you changed only...
275
Posted By MadeInGermany
Put the global substitution first: sed 's/ *|...
Put the global substitution first:
sed 's/ *| */|/g; s/^|//; s/|$//'
275
Posted By RudiC
This works with my GNU sed 4.4: sed...
This works with my GNU sed 4.4:



sed -r 's/(^\|| |\|$)//g' file
3464114|10|REPORT|CA|1|0|4825400|0|213167|939396524
275
Posted By rdrtx1
sed 's/^ *[|] *//; s/ *[|] */|/g; s/ *[|] *$//'...
sed 's/^ *[|] *//; s/ *[|] */|/g; s/ *[|] *$//' file.out > format.out
496
Posted By vgersh99
In addition to double-quoting $1 in print_log,...
In addition to double-quoting $1 in print_log, I'd enable set -x in the script and in the function call and see what comes out....
496
Posted By vgersh99
Actually it's the same problem with echo as you...
Actually it's the same problem with echo as you had with execute.
Double-quote the argument to the command.
283
Posted By RudiC
In order to retain the special structure of the...
In order to retain the special structure of the fourth line's $12, try
awk -F\; '$12 == $12+0 {$12 = sprintf ("%03d", $12)} 1' OFS=";" file...
264
Posted By Scrutinizer
For sort to work you also have to specify the...
For sort to work you also have to specify the field separator. You can try:
sort -ut\; -k1,1 fileHowever, this is not standard (POSIX) behavior for sort and cannot be relied upon and some sorts will...
Showing results 1 to 25 of 104

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