We help IT Professionals succeed at work.

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

cmurugavel
cmurugavel asked
on
3,433 Views
Last Modified: 2012-06-27
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
Comment
Watch Question

ozo
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2015

Commented:
sed s/y/Y/
CERTIFIED EXPERT
Top Expert 2007
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
ozo
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2015
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
I like to share the mark to ozo and tintin. Let me know how to do it
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
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.