The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Lowercase to Uppercase ggovotsis AIX 7 10-16-2008 11:07 AM
How to replace any char with newline char. mightysam Shell Programming and Scripting 5 09-18-2008 09:15 PM
replacing char with string phani_sree High Level Programming 1 11-20-2006 08:57 AM
after i convert upper case to lowercase Alex20 Shell Programming and Scripting 1 03-07-2005 04:07 PM
uppercase to lowercase webex Shell Programming and Scripting 4 01-03-2002 02:15 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-02-2006
Browser_ice Browser_ice is offline
Registered User
  
 

Join Date: Nov 2005
Location: Canada
Posts: 110
replacing all 4 first upper char of every rec to lowercase ?

I have a file where some records have been updated the wrong way and need to fix it quickly since the amount can be alot.

Every record where any of the first 4 characters are in upper case need to be changed to lowercase.

Records can have '#' in position-1 for comments. These musn't be changed.

How do I do it with VI ?

If not with VI, with what and how ?

Last edited by Browser_ice; 08-02-2006 at 11:34 AM.. Reason: error
  #2 (permalink)  
Old 08-02-2006
Browser_ice Browser_ice is offline
Registered User
  
 

Join Date: Nov 2005
Location: Canada
Posts: 110
can you move this thread to the right place ?

it got posted in the wrong place by mistake
  #3 (permalink)  
Old 08-02-2006
tmarikle tmarikle is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2005
Posts: 683
Gosh, I'm not sure if this can be done in vi but here's how to do it via awk:

Code:
nawk '{
    sub(/^[A-Z][A-Z][A-Z][A-Z]/, tolower(substr($0,1,4)) substr($0,5),$0)
} 1' yourfile > newfile
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:13 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0