Search Results

Search: Posts Made By: csierra
3,578
Posted By RudiC
Try awk -v points=5 ' NR == 1 {next ...
Try
awk -v points=5 '

NR == 1 {next
}

{a[(NR-1) % points] = $2
if ((NR-1)>=points) {total_a = 0
for (i = 0; i < points; ++i) ...
2,348
Posted By MadeInGermany
Pure Posix / quite portable is ps -e -o pid= -o...
Pure Posix / quite portable is
ps -e -o pid= -o etime= -o args=The etime has the further advantage that it is already the difference current_date - stime.
For example
ps -e -o pid= -o etime= -o...
2,348
Posted By Chubler_XL
I'm fairly sure Solaris 10 has the /proc...
I'm fairly sure Solaris 10 has the /proc filesystem so you should be able to look at the ctime of the /proc/<pid> directory.

You should be able to verify this for yourself by picking a long...
4,540
Posted By jayan_jay
$ sed 's,^Rf.Col_Estabil,&.csv,g' infile
$ sed 's,^Rf.Col_Estabil,&.csv,g' infile
4,540
Posted By yazu
For a quick&dirty solution just this should work...
For a quick&dirty solution just this should work (in 99.9% cases):
awk -F, '{print > $1 ".csv"}' INPUTFILE
4,540
Posted By agama
Something like this should do what you need: ...
Something like this should do what you need:


awk -F , '
{
if( lastf && $1 != lastf )
close( lastf );
lastf = $1;
printf( "%s\n", $0 ) >lastf ".csv";
}' input-file

...
4,297
Posted By rdcwayx
awk -F, -v points=5 ' { a[NR % points]...
awk -F, -v points=5 '

{
a[NR % points] = $2;
b[NR % points] = $3;
if(NR>=points) {
total_a = 0;
total_b = 0;
for (i = 0; i < points; ++i)
{ total_a = total_a + a[i];
...
2,324
Posted By rdcwayx
Something like this? awk -F , -v i=5 '{...
Something like this?

awk -F , -v i=5 '{ sum2+=$2;sum3+=$3}
NR%i {print;next}
{ print $0, (sum2>last2)?"UP":(sum2==last2)?"STABLE":"DOWN",...
2,479
Posted By dr.house
Ad hoc: #! /bin/bash cat ascii.file...
Ad hoc:


#! /bin/bash

cat ascii.file | \
while read LINE
do
TIME=$( echo $LINE | awk -F ',' '{ print $2 }' | sed 's/://' )
if [ $TIME -ge 1200 ] && [ $TIME -le 2200 ]
then
echo...
2,479
Posted By Franklin52
Something like this? awk -F",|:" '$2 > 11 &&...
Something like this?

awk -F",|:" '$2 > 11 && $2 < 23' file
3,772
Posted By rdcwayx
awk -F, '{ {date[$3]=$3} {if (open[$3]=="")...
awk -F, '{
{date[$3]=$3}
{if (open[$3]=="") open[$3]=$5}
{if (high[$3]<$6) high[$3]=$6}
{if (low[$3]=="") low[$3]=$7}
{if (low[$3]>$7) low[$3]=$7}
{closep[$3]=$8}
{vol[$3]+=$9}
}
END {for (i...
3,772
Posted By rdcwayx
awk -F, 'split($3,a,"/") {print...
awk -F, 'split($3,a,"/") {print $1,$2,a[3]a[1]a[2],$4,$5,$6,$7,$8}' OFS=, urfile
3,772
Posted By ahmad.diab
use below:- gawk -F"," '{...
use below:-



gawk -F"," '{ split($3,a,"\/") ; if ( a[2] < 10) {$3=a[3]a[1]"0"a[2]}
else {$3=a[3]a[1]a[2] }}1' OFS="," file.txt


:D:D:D:D
55,922
Posted By binlib
It seems to be a bug caused by l10n/i18n, do ...
It seems to be a bug caused by l10n/i18n, do
LC_ALL=C sort -n -t/ ...
55,922
Posted By joeyg
Two different delimiters can be a pain
What about:
cat csierra.txt | tr "," "/" | sort -n -t"/" -k3 -k1 -k2 | gawk -F"/" '{print $1"/"$2"/"$3","$4}'
55,922
Posted By hergp
Try sort -n -t"," -k1.7,1.10 -k1.1,1.2...
Try
sort -n -t"," -k1.7,1.10 -k1.1,1.2 -k1.4,1.5 file
This only works, if the date is always exactly 10 characters long.
2,226
Posted By guruprasadpr
Hi awk 'NR==FNR{a[$1]=$2;next;}{if ($1 in a)...
Hi

awk 'NR==FNR{a[$1]=$2;next;}{if ($1 in a) print $1, $2/a[$1];else print;}' file2 file1

For those dates in file1 which does not have a matching date in file2, the above will print the line...
2,362
Posted By clx
something like.. #! /usr/local/bin/bash ...
something like..

#! /usr/local/bin/bash
exec 6<f2
while IFS=, read v1 v2 v3 v4 v5 v6
do
IFS=, read n1 n2 n3 n4 n5 n6 <&6
if [ "$v1" = "$n1" ]; then
echo...
2,362
Posted By anurag.singh
Assuming every record will have 6 fields: ...
Assuming every record will have 6 fields:

awk -F, 'NR==FNR{a[$1]=$2;b[$1]=$3;c[$1]=$4;d[$1]=$5;e[$1]=$6;next;}{if(a[$1]) print $1", "$2/a[$1]", "$3/b[$1]", "$4/c[$1]", "$5/d[$1]", "$6/e[$1]; else...
7,924
Posted By Scrutinizer
If you mean permutations, rather than...
If you mean permutations, rather than combinations, this can be done relatively easily using recursion in a shell that has local variables:
#!/bin/ksh
function perm {
typeset p=$1 s=$2 i
for...
7,924
Posted By yinyuemi
try: paste -sd " " file | awk '{split($0,a,"...
try:
paste -sd " " file | awk '{split($0,a," ")}END{
for(i=1;i<=NF;i++) {printf $i;for(j=2;j<=NF;j++) {printf "+"a[j]}print "="}
}'
1+2+3+4+5=
2+2+3+4+5=
3+2+3+4+5=
4+2+3+4+5=
5+2+3+4+5=
7,924
Posted By kurumi
Ruby(1.9.1+) $ ruby -e...
Ruby(1.9.1+) $ ruby -e 'a=File.read("file").split; a.permutation(a.length).to_a.each {|x| puts x.join}'
9,700
Posted By Chubler_XL
Permutations: awk ' function perm(l,v,i)...
Permutations:

awk '
function perm(l,v,i) {
for(i in A) {
if(l < length(A))
perm(l+1, (v?v"+":x)i);
else print v"+"i;
}
}
{ A[$0] }
END {
perm(1);
} '...
11,238
Posted By Chubler_XL
cor.awkawk -F, -v c="$1" ' { d=$1;...
cor.awkawk -F, -v c="$1" '
{ d=$1; for(i=c;i;i--) {
x[i]=x[i-1]
y[i]=y[i-1] }
x[0]=$3
y[0]=$4
}
END { for(i=0;i<c;i++) {
sx+=x[i]
sy+=y[i]
...
Showing results 1 to 24 of 24

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