• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3404
  • Last Modified:

UNIX::SED::How to replace numericacharacter (lower case to upper case) in the .txt file ?

Hi,

I have a records like this in the file.txt:
20071010                Add     0       625306  1800076         USD     5y      1825    2555    32733.29
20071010                Add     0       625306  1800076         USD     3M      1825    2555    32733.29
20071010                Add     0       625306  1800076         USD     10y      1825    2555    32733.29

In the 7th field, I have a data 5y, 3M, 10y

I would like to change the all small letter to upper case (eg: 5y to 5Y and 10y to 10Y)

Can you tell me how can we do this in SED ?

I have tried with below command, but it's not showing correctly.  Please advise.

sed 's/[0-9]*y/[0-9]*Y/g' file.txt
0
cmurugavel
Asked:
cmurugavel
2 Solutions
 
ozoCommented:
sed s/y/Y/
0
 
TintinCommented:
sed "s/\([0-9]\)y/\1Y/g" file.txt
0
 
ozoCommented:
to only change y folllowing a digit
sed 's/\([0-9]\)y/\1Y/g'
0
 
cmurugavelAuthor Commented:
I like to share the mark to ozo and tintin. Let me know how to do it
0
 
ghostdog74Commented:
you can use sed to do that, however be careful of other letters in other columns..awk is a better tool to use. Unless you have restrictions on the tools to use, you can try this:

   
awk '{$7=tolower($7);print}' "file" > newfile
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now