awking two columns

Hey ppl
I have two columns with random values. i need to insert the 1st row of the first column with the highest number of the two rows in the first column and vice versa. some thing like this. I'm sorry If my question is unclear...:rolleyes:

input
col1 col2
12...11
11...14
34...45
14...67
31...21

output
col1 col2
12...11
14...11
45...34
67...14
31...21

Not able to understand..make it clear plz....?

Thanks
Sha

its about the two values of two columns
I need to make the first column values will be higher compared to the subsequent column 2 values

11 ..12 to 12.. 11

use below one ...hope this should work..

sed 's/\.\.\./,/g' inputfile |awk -F"," '{if($2 > $1) {print $2,$1} else {print $1,$2}}'

output:
12 11
14 11
45 34
67 14
31 21

if you want the same format output then use below one:

sed 's/\.\.\./,/g' out.lst|awk -F"," 'OFS="..." {if($2 > $1) {print $2,$1} else {print $1,$2}}'

output:
12...11
14...11
45...34
67...14
31...21

Thanks
Sha

sed 's/\.\.\./,/g'

wht this mean

In your input file ..you have used delimeter..something like this "..."
so before i proceed with comparing column to make it easy myself...i changed delimeter from "..." to ","

Thanks
Sha

actually I have tab in between two file and I need result with tab

thanx

thanx alot its working l

This command will give you the tab output:

sed 's/\.\.\./,/g' input file|awk -F"," 'OFS="\t" {if($2 > $1) {print $2,$1} else {print $1,$2}}'

or

if you are using input file with delimeter tab..then use below one:
awk -F"\t" 'OFS="\t" {if($2 > $1) {print $2,$1} else {print $1,$2}}' inputfile

Thanks
Sha

Hi all, how can I modify the last solution (that awk's a tab delimited file) in order to do the following:

file.tab contains 5 fields:

1 1 text1
2 1 text1
3 1 text1
3 2 text2
3 3 text2
4 1 text1

I would like to merge $3 whenever subindex $2 is larger than 1.
The goal is to output only one line for each unique index $1:

1 1 text1
2 1 text1
3 1 text1,text2,text2
4 1 text1

And only unique lines should be added

1 1 text1
2 1 text1
3 1 text1,text2
4 1 text1

Thanks in advance!

-Per

if i understand your question correctly it's very easy
make the first column as one file
sort -u file1 --command to srt the file
make other columns as one file sort -u file2 ---sort the file using the same command
join file1 file2 ---this command joins the unique lines in a same line

sort -u file1
sort -u file2
join file1 file2