Hi,
1) I have a file (temp.lst) like this :
TABLE_A1
TABLE_C
TABLE_D
TABLE_B
TABLE_A
TABLE_E
TABLE_G
TABLE_F
TABLE_A2
I want to select the paragraph which has exactly TABLE_A in it ... (not TABLE_A1 or TABLE_A2)
The current solution I have is :
cat temp.lst|sed -e '/./{H;$!d;}' -e 'x;/TABLE_A/!d;'
But this prints out TABLE_A1 & TABLE_A2 as well ...
Is there a way to select the paragraph with exactly TABLE_A only ?
2) In the above question, I also need to dynamically select the table names from inside a loop ...
seq_tables_common.lst is a list of tables ... containing :
TABLE_A
TABLE_C
TABLE_D
TABLE_B
TABLE_E
TABLE_G
TABLE_F
cat seq_tables_common.lst|while read line
do
cat temp.lst|sed -e '/./{H;$!d;}' -e 'x;/$line/!d;' > $exp/tmp/$line.lst
done
But it doesn't select $line dynamically ... if I hard code the table names as TABLE_A, TABLE_A1 it works fine ... but substitution from within the single quotes is failing ...
Any ideas to fix these ?
Thanx in advance!
-Maria
1) I have a file (temp.lst) like this :
TABLE_A1
TABLE_C
TABLE_D
TABLE_B
TABLE_A
TABLE_E
TABLE_G
TABLE_F
TABLE_A2
I want to select the paragraph which has exactly TABLE_A in it ... (not TABLE_A1 or TABLE_A2)
The current solution I have is :
cat temp.lst|sed -e '/./{H;$!d;}' -e 'x;/TABLE_A/!d;'
But this prints out TABLE_A1 & TABLE_A2 as well ...
Is there a way to select the paragraph with exactly TABLE_A only ?
2) In the above question, I also need to dynamically select the table names from inside a loop ...
seq_tables_common.lst is a list of tables ... containing :
TABLE_A
TABLE_C
TABLE_D
TABLE_B
TABLE_E
TABLE_G
TABLE_F
cat seq_tables_common.lst|while read line
do
cat temp.lst|sed -e '/./{H;$!d;}' -e 'x;/$line/!d;' > $exp/tmp/$line.lst
done
But it doesn't select $line dynamically ... if I hard code the table names as TABLE_A, TABLE_A1 it works fine ... but substitution from within the single quotes is failing ...
Any ideas to fix these ?
Thanx in advance!
-Maria