Search Results

Search: Posts Made By: Paulwintech
1,069
Posted By methyl
This line overwrites the system variable $PATH....
This line overwrites the system variable $PATH. From that point on your script will not be able to find any programs without using the full path.
Choose another name for this variable. Something...
5,310
Posted By itkamaraj
can you try this the below code is to...
can you try this

the below code is to remove the non-printing characters


perl -lane '$_=~ tr/\x20-\x7f//cd;print $_' input.txt > output.txt
5,310
Posted By balajesuri
Please use code tags...
Please use code tags (https://www.unix.com/how-post-unix-linux-forums/167686-forum-video-tutorial-how-use-code-tags.html) for codes and data samples. Otherwise extra spaces would be truncated and the...
5,310
Posted By balajesuri
Perl, ok? perl -ane '$x{$F[0]}+=$F[1];...
Perl, ok?
perl -ane '$x{$F[0]}+=$F[1]; $y{$F[0]}+=$F[2]; END {for(sort keys %x){print "$_ $x{$_} $y{$_}\n"}}' inputfile
5,310
Posted By ctsgnb
It should work please not that there is a...
It should work
please not that there is a double space in the given sed rule :

s/ */ /g is s/<space><space>*/<space>/g

Please copy paste exactly what you have tried because for me it works...
2,221
Posted By Scrutinizer
If infile is sorted: awk 'p!=$1{if(p)print...
If infile is sorted:
awk 'p!=$1{if(p)print p,s,t;s=t=x;p=$1}{s+=$2;t+=$3}END{print p,s,t}' infile
otherwise:
sort infile | awk 'p!=$1{if(p)print p,s,t;s=t=x;p=$1}{s+=$2;t+=$3}END{print p,s,t}'
2,221
Posted By durden_tyler
$ $ cat f60 bag 12 12 bag 18 15 bags 15...
$
$ cat f60
bag 12 12
bag 18 15
bags 15 13
bags 15 14
blazer 24 24
blazer 33 32
boots 19 15
$
$ perl -lane '$i=0; map{$x{$F[0]}->[$i++]+=$_} @F[1,2]}{for (sort keys %x){print "$_...
5,310
Posted By ctsgnb
awk '{a[$1]+=$2;b[$1]+=$3}END{for (i in a) print...
awk '{a[$1]+=$2;b[$1]+=$3}END{for (i in a) print i,a[i],b[i]}' yourfile
Note that this code assume your file is already sorted on its first-column

If you want the output sorted :
awk...
2,221
Posted By bartus11
Try: awk '{a[$1]+=$2;b[$1]+=$3}END{for (i in a)...
Try: awk '{a[$1]+=$2;b[$1]+=$3}END{for (i in a) print i,a[i],b[i]}' file
Showing results 1 to 9 of 9

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