Search Results

Search: Posts Made By: hydrabane
Forum: Linux 11-27-2008
3,733
Posted By manikantants
awk '{ if (NR==FNR) { my_array[$1]=$1; next;} if...
awk '{ if (NR==FNR) { my_array[$1]=$1; next;} if ( $1 in my_array ) {print $0}}' file1 file2

try above one liner. Not sure about the performance.
1,473
Posted By Corona688
awk '{ ORIG=$0 getline <"numbers" ...
awk '{ ORIG=$0
getline <"numbers"
if ($1 < 0.9)
{
$0=ORIG
$1=0
$2=0
}
else { $0=ORIG }...
2,503
Posted By alister
Yet another: tr -s ' \t' '\n\n' < file | awk...
Yet another:
tr -s ' \t' '\n\n' < file | awk '$0>max+0 {max=$0} !(NR%3) {print max; max=0}' > out


Test run:
$ cat data
0.111 0.111 0.788 0.101 0.800 0.099 0.500 0.255 0.245
0.234 0.675 0.091...
2,503
Posted By yazu
Another awk: awk ' ...
Another awk:
awk '
function max (a, b) {
return a>b ? a : b;
}
{ for (i=1; i<=NF; i+=3) {
...
2,503
Posted By Chubler_XL
Is this what you were after: awk ' {...
Is this what you were after:

awk '
{ for(i=1;i<=NF;i++) {
max=$i>max?$i:max;
if(!(++cnt%3)) {
print max;
max=-999;
}}}
END { if(cnt%3) print max }'...
2,503
Posted By Corona688
It's not the ugly triply-nested for-loop that's...
It's not the ugly triply-nested for-loop that's making it slow, it's the running of multiple external processes per loop. It's wasteful to run awk, grep, sed, and so forth for individual lines --...
1,270
Posted By yazu
sed 's/[^ ]*/& &/g' INPUTFILE
sed 's/[^ ]*/& &/g' INPUTFILE
1,270
Posted By anuragpgtgerman
sed 's/[^ ]*/& &/g' INPUTFILE
sed 's/[^ ]*/& &/g' INPUTFILE
1,270
Posted By danmero
echo entry1 entry2 entry3 entry4 |awk...
echo entry1 entry2 entry3 entry4 |awk '{for(;++i<=NF;)$i=$i FS $i}1'
1,270
Posted By yinyuemi
echo 'entry1 entry2 entry3 entry4' |perl -alne...
echo 'entry1 entry2 entry3 entry4' |perl -alne 'print map {$_ x 2} map{$_." "} @F'
entry1 entry1 entry2 entry2 entry3 entry3 entry4 entry4
Showing results 1 to 10 of 10

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