The UNIX and Linux Forums  

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
code that reads commands from the standard i/p and executes the commands Phrozen Smoke High Level Programming 4 01-21-2007 11:06 PM
need help with some commands please mujtba UNIX for Dummies Questions & Answers 2 01-14-2005 11:49 AM
sed commands dbrundrett Shell Programming and Scripting 7 09-28-2004 02:11 PM
commands kironpmullamkuz Security 2 06-27-2002 08:45 PM
BDS Commands bbutler3295 UNIX for Dummies Questions & Answers 3 03-04-2002 05:28 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 09-16-2006
Registered User
 

Join Date: Sep 2006
Posts: 5
vi commands

Hi,

a. How can we replace one more spaces with a single space in vi?
b. Replace one more spaces following a full stop or a comma with two spaces.?
c. Delete all blank line?
d. Insert > and a space at the start of every line in the file?
e. Reverse the order of lines in a file?
f. In a file, how can two consecutive lines be combined into one?

thanks,
tictactoe
Reply With Quote
Forum Sponsor
  #2  
Old 09-16-2006
Supporter
 

Join Date: Jul 2006
Posts: 156
a. :%s/\ */ /g;
b. :%s/[,.]\ */ /g;
c. % ! grep .
d. %s/^/> /g
e. Not quite sure what you mean on this one.
f. Place cursor on top line, press J ( shift + j ) to join the lines.

I haven't tried these, but they should work. You may have to modify them slightly. You should google for "regular expressions".
Reply With Quote
  #3  
Old 09-17-2006
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,610
Quote:
Reverse the order of lines in a file?
Code:
:g/.*/m0
Quote:
Delete all blank line?
Code:
:v/./d
or
Code:
:g/^$/d
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
regex, regular expressions

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 03:57 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0