convert specific field to upper case in file

Hi Friends,

I have a file1.txt as below

I want to convert the date fields in to upper case field3 and field 6

output.txt

Plz help.

awk -F\| '{$3=toupper($3);$6=toupper($6)}1' OFS=\| file

With Perl:

perl -pe 's/((?:.*?\|){2})(.*?)((?:\|.*?){2})(\|.*?)(\|.*)/\1\U\2\E\3\U\4\E\5/' file
1 Like

@Elixir : Thanks for the reply. it works as expected.