LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-07-2012, 08:21 PM   #1
romeo0307
LQ Newbie
 
Registered: Apr 2012
Posts: 16

Rep: Reputation: Disabled
Fixing the case problems in a file with a tr command...


My last question today. I swear I won't bother you for a while again

I have 2 files:

File1 and File2

File1 has the following sentence:

Trust but Verify

File2 has the following sentence:

ronald REAGAN

I need to fix the case problems using the tr command and possibly other commands and take the output and put it into 2 new files: File3 and File4.

Can you guys help please?
 
Old 05-07-2012, 10:37 PM   #2
towheedm
Member
 
Registered: Sep 2011
Location: Trinidad & Tobago
Distribution: Debian Stretch
Posts: 612

Rep: Reputation: 125Reputation: 125
Without doing your homework for you, here are a few pointers. First, 'tr' translates between one character set and another (it also deletes and squeezes char sets), it cannot be used to correct words with wrong cases. For example:
Code:
echo "ronald REAGAN | tr [a-z] [A-Z]
RONALD REAGAN
What exactly should the correct case for 'Trust and Verify' be?

I would probably use sed, but there may be other utils.
 
Old 05-08-2012, 02:36 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
Just a slight edit on the above information:

1. Second double quote missing

2. As there are no square brackets in the input then they are not required:
Code:
echo "ronald REAGAN" | tr a-z A-Z
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
fdisk command and fixing paritions devUnix Linux - Server 4 08-24-2012 11:45 AM
Script/Command Require in case command hangs rajaniyer123 Linux - General 1 04-03-2012 06:45 PM
[SOLVED] Text file - needs 'fixing' JGuillou Linux - Newbie 11 05-05-2010 09:06 AM
Dependency problems, how does one go about fixing? miner49er Debian 17 03-14-2006 02:59 PM
I need help fixing my Networking problems! Cyrion Linux - Networking 2 08-05-2004 05:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration