LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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, 09: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, 11:37 PM   #2
towheedm
Member
 
Registered: Sep 2011
Location: Trinidad & Tobago
Distribution: Debian Jessie
Posts: 592

Rep: Reputation: 119Reputation: 119
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, 03:36 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,427

Rep: Reputation: 2827Reputation: 2827Reputation: 2827Reputation: 2827Reputation: 2827Reputation: 2827Reputation: 2827Reputation: 2827Reputation: 2827Reputation: 2827Reputation: 2827
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 12:45 PM
Script/Command Require in case command hangs rajaniyer123 Linux - General 1 04-03-2012 07:45 PM
[SOLVED] Text file - needs 'fixing' JGuillou Linux - Newbie 11 05-05-2010 10:06 AM
Dependency problems, how does one go about fixing? miner49er Debian 17 03-14-2006 03:59 PM
I need help fixing my Networking problems! Cyrion Linux - Networking 2 08-05-2004 06:32 PM


All times are GMT -5. The time now is 01:08 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration