file d1 contain:
1 A
2 B
3 C
4 D
5 E
6 F
7 G
8 H
9 I
I have this script: test.script
#!/bin/ksh
DAY=`date +%y%m%d`
H=`date +%H`
D=`date +%d`
cat d1 | while read line
do
a=$(echo $line | awk '{print $1}')
n=$(echo $line | awk '{print $2}')
awk '{print $0, $n}' d1 >> d2
done
./test.script
cat d2
1 A 1 A
2 B 2 B
3 C 3 C
4 D 4 D
5 E 5 E
6 F 6 F
7 G 7 G
8 H 8 H
9 I 9 I
1 A 1 A
2 B 2 B
3 C 3 C
4 D 4 D
5 E 5 E
6 F 6 F
7 G 7 G
8 H 8 H
9 I 9 I
1 A 1 A
2 B 2 B
3 C 3 C
4 D 4 D
5 E 5 E
6 F 6 F
7 G 7 G
8 H 8 H
9 I 9 I
1 A 1 A
2 B 2 B
3 C 3 C
4 D 4 D
5 E 5 E
6 F 6 F
7 G 7 G
8 H 8 H
9 I 9 I
1 A 1 A
2 B 2 B
3 C 3 C
4 D 4 D
5 E 5 E
6 F 6 F
7 G 7 G
8 H 8 H
9 I 9 I
1 A 1 A
2 B 2 B
3 C 3 C
4 D 4 D
5 E 5 E
6 F 6 F
7 G 7 G
8 H 8 H
9 I 9 I
1 A 1 A
2 B 2 B
3 C 3 C
4 D 4 D
5 E 5 E
6 F 6 F
7 G 7 G
8 H 8 H
9 I 9 I
1 A 1 A
2 B 2 B
3 C 3 C
4 D 4 D
5 E 5 E
6 F 6 F
7 G 7 G
8 H 8 H
9 I 9 I
1 A 1 A
2 B 2 B
3 C 3 C
4 D 4 D
5 E 5 E
6 F 6 F
7 G 7 G
8 H 8 H
9 I 9 I
1 A 1 A
2 B 2 B
3 C 3 C
4 D 4 D
5 E 5 E
6 F 6 F
7 G 7 G
8 H 8 H
9 I 9 I
I expect:
1 A A
2 B A
3 C A
4 D A
5 E A
6 F A
7 G A
8 H A
9 I A
1 A B
2 B B
3 C B
4 D B
5 E B
6 F B
7 G B
8 H B
9 I B
1 A C
2 B C
3 C C
4 D C
5 E C
6 F C
7 G C
8 H C
9 I C
on and on.....
Given that:
awk '{print $0, "A"}' d1
1 A A
2 B A
3 C A
4 D A
5 E A
6 F A
7 G A
8 H A
9 I A
Thanks!