Appending text at the beginning and end of second column of each line
Hi,
I am creating a symbol table as follows: Field Value field1 value1 field2 value2 field3 value3 A single TAB space is present between FIELD and the VALUE Now I am required to modify the VALUE column so that the symbol table becomes Field Value field1 <s> value1 </s> field2 <s> value2 </s> field3 <s> value3 </s> In this case, there is a single space between <s> and value* and there is a single space between value* and </s>. Also, as usual, there is a TAB separating FIELD and VALUE tabs. How can I do this? I am to implement this using either AWK, SED or VI EDITOR |
Hi,
with sed, you can use: Code:
sed -e "s/\t/\t \<s\> /" -e "s/$/ \<\/s\>/" Code:
awk '{gsub(/\t/, "\t <s> "); gsub(/$/, " </s> "); print}' If there are more than two columns, it would be Code:
awk 'BEGIN{FS=OFS="\t"}$2="<s> "$2" </s>"' |
@OP: please show what you've done so far
|
All times are GMT -5. The time now is 04:37 AM. |