Search Results

Search: Posts Made By: unme
1,369
Posted By RudiC
For data exactly like your sample data, this...
For data exactly like your sample data, this simple approach might do as well:awk -F, ' $1 in X {$1=X[$1]} {X[$2]=$1} 1' OFS="," file
Job1,JC1
Job1,JC2
Job1,JC3
Job1,JA1
Job1,JA4
JG,KA
Job1,JJ
1,369
Posted By Don Cragun
Personally, when shell scripting using arrays for...
Personally, when shell scripting using arrays for things like this, I prefer awk:
#!/bin/ksh
awk '
BEGIN { FS = OFS = "," }
NR == FNR {
tr[$2] = $1; next
}
{ while($1 in tr) $1 = tr[$1] }
1'...
1,676
Posted By derekludwig
With respects to Scrutinizer, if the XML tags are...
With respects to Scrutinizer, if the XML tags are nested on the same line, are empty, have multiples on a line, or span multiple lines, as in:
<?xml version="1.0" encoding="UTF-16"?>
<P1 >
<C1...
1,676
Posted By Scrutinizer
With this particular format you could try: sed...
With this particular format you could try:
sed 's/<\([^>]*\)>\(<[^>]*>\)$/\1\2/' file
1,676
Posted By derekludwig
The issue will be determining what is a valid XML...
The issue will be determining what is a valid XML tag and what is data that appears between "<" and ">". Is it always numeric? Are there negative numbers? Character strings? With or without...
2,028
Posted By Chubler_XL
how about this: awk -F, ' BEGIN {...
how about this:
awk -F, '
BEGIN { cols=split("A,B,C", a);}
{ c[$1];v[$1,$2]+=$3 }
END {
printf "XX"
for (i=1;i<=cols;i++) printf ",%s", a[i]
printf "\n"
for (j in c) {
...
2,028
Posted By Scrutinizer
Two suggested modifications to ritakadm's...
Two suggested modifications to ritakadm's approach:
val[$1,$2]+=$3
and
val[j,i]+0
2,028
Posted By ritakadm
Not the most elegant solution, but try...
Not the most elegant solution, but try this,,untested..sorry i missed on the sum part...


awk -F, '{a[$1","$2]+=$3;}END{for(i in a)print i", "a[i];}' file > infile


awk -F, '{cntry[$1];...
1,619
Posted By Yoda
Here is an awk approach: awk -F, ' { ...
Here is an awk approach:
awk -F, '
{
D[$1,$2,$4,$6]++
R[$1,$2,$4,$6] = R[$1,$2,$4,$6] ? R[$1,$2,$4,$6] RS $0 : $0
}
END {
...
1,504
Posted By pamu
awk -F "<VName>|</VName>" '{s=s?s"\n"$0:$0} ...
awk -F "<VName>|</VName>" '{s=s?s"\n"$0:$0}
/^<BOOK><Info>/{fn=$2}
/<\/BOOK>$/{print s > fn ;s=""}' file
1,837
Posted By raj_saini20
$awk -F"\"" 'BEGIN{i=1;print "Id,Name,Prompt"}...
$awk -F"\"" 'BEGIN{i=1;print "Id,Name,Prompt"} ($1 ~ /Id|Name|Prompt/){if(i==4){print x;i=1};i++;printf $2","}END{print x}' inputfile
1,837
Posted By radoulov
awk -v c="Id Name Prompt" -v OFS=, 'BEGIN { n...
awk -v c="Id Name Prompt" -v OFS=, 'BEGIN {
n = split(c, t)
for (i = 0; ++i <= n;) {
printf "%s", (t[i] (i < n ? OFS : ORS))
v[t[i]]
}
}
$1 in v { get_val($1) }
/END RECGET/...
Showing results 1 to 12 of 12

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