![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| More than transposing! | bulash | UNIX Desktop for Dummies Questions & Answers | 3 | 04-11-2008 02:20 PM |
| Transposing string | unibboy | Shell Programming and Scripting | 3 | 02-13-2008 03:12 PM |
| Major Awk problems (Searching, If statements, transposing etc.) | Blivo | Shell Programming and Scripting | 2 | 09-05-2007 03:41 AM |
| file transposing | mskcc | Shell Programming and Scripting | 24 | 08-04-2005 08:23 AM |
| transposing letters | myscsa2004 | Shell Programming and Scripting | 4 | 05-12-2004 07:11 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#8
|
|||
|
|||
|
i dunno the syntax in sun/solaris. i got the same result as yours.
|
| Forum Sponsor | ||
|
|
|
#9
|
||||
|
||||
|
Quote:
Code:
2 3 4 3 0 7 9 1 5 6 7 |
|
#10
|
|||
|
|||
|
alternatively in Python:
Code:
store = {}
all = open("datafile.txt").readlines()
for items in all:
key,value = items.split()
if store.has_key(key):
store[key].append(value)
else:
store[key] = [value]
for i in sorted(store.keys()):
print i, ' '.join(store[i])
Code:
1 5 6 7 2 3 4 3 7 0 9 |
|
#11
|
|||
|
|||
|
Ruby:
Code:
h = Hash.new{[]}
while line = gets
k,v = line.split
h[k] <<= v
end
puts h.sort.map{|a| a.join " "}
|
|
#12
|
|||
|
|||
|
Code:
for i in `awk '{print $1}' file | uniq`
do
echo $i `grep $i file | awk '{print $2}'`
done
cheers, sayon |
|
#13
|
|||
|
|||
|
Quote:
Code:
>cat s 1 5 1 6 1 7 2 3 2 4 3 7 3 0 3 9 11 2 11 0 Code:
>echo 1 `grep 1 s | awk '{print $2}'`
5 6 7 2 0
Code:
for i in `awk '{print $1}' s | uniq`
do
awk -F" " 'BEGIN{x='$i'} { if( $1=='$i' ) x=x" "$2} END{print x}' s
done
Code:
>newoutput 1 5 6 7 2 3 4 3 7 0 9 11 2 0 |
|
#14
|
|||
|
|||
|
Quote:
anyway, for the sample input data, i got 1 5 6 7 2 3 4 3 3 7 0 9 |
|||
| Google The UNIX and Linux Forums |