LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-18-2002, 10:38 AM   #1
Trev
LQ Newbie
 
Registered: Feb 2002
Location: South Africa
Distribution: Slackware 8, Debian 2, Mandrake 8
Posts: 5

Rep: Reputation: 0
Editing Question...


Hi,

Firstly I see alot of LFS listed by people's distrobutions, is there a website were i can look for more info?

I would just like to know, i have a text files lets say it's the aliases file what i want to do is fix the layout up.

Instead of having:
user1: blah@blaho.com
user2: ____hello@hello.com
user4: ___test@test.com

I want to align the left and the right column
so all the text is under eachother for the right column
is there any command u can use in vi, sed to do this?

cat /etc/aliases | tr -s ' ' $'\t' <-- this only puts then in tabs doesn't aline them

Last edited by Trev; 02-18-2002 at 12:10 PM.
 
Old 02-18-2002, 12:19 PM   #2
dorward
Member
 
Registered: Sep 2001
Distribution: Gentoo
Posts: 760

Rep: Reputation: 31
Re: Editing Question...

Quote:
Originally posted by Trev
Hi,

Firstly I see alot of LFS listed by people's distrobutions, is there a website were i can look for more info?
http://www.linuxfromscratch.org.
 
Old 02-18-2002, 01:38 PM   #3
Malicious
Member
 
Registered: Jan 2002
Location: Galveston Island
Distribution: suse, redhat
Posts: 208

Rep: Reputation: 30
For the specific lines (assuming the _ are spaces):
user1: blah@blaho.com
user2: ____hello@hello.com
user4: ___test@test.com

A general regular expression search and replace:

s/\(user[0-9]:\) +/\1 /

In vi - :%s/\(user[0-9]:\) +/\1 /

Using sed:

cp /etc/aliases /etc/aliases.bak
sed 's/\(user[0-9]:\) +/\1 /' /etc/aliases.bak > /etc/aliases
 
Old 02-18-2002, 02:47 PM   #4
Trev
LQ Newbie
 
Registered: Feb 2002
Location: South Africa
Distribution: Slackware 8, Debian 2, Mandrake 8
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks for the reply, when i run :s/\(user[0-9]:\) +/\1 /
from vi, I get an error "substitution failed" any ideas?
 
Old 02-18-2002, 05:05 PM   #5
Malicious
Member
 
Registered: Jan 2002
Location: Galveston Island
Distribution: suse, redhat
Posts: 208

Rep: Reputation: 30
Did you miss the percent sign or is it a typo in your message?

Should be :%s... not :s...

Without the line range (% = all), s will only search the current line.
 
Old 02-18-2002, 05:21 PM   #6
Trev
LQ Newbie
 
Registered: Feb 2002
Location: South Africa
Distribution: Slackware 8, Debian 2, Mandrake 8
Posts: 5

Original Poster
Rep: Reputation: 0
Sorry was a typo on my post, the command still does not work.
 
Old 02-18-2002, 07:33 PM   #7
Malicious
Member
 
Registered: Jan 2002
Location: Galveston Island
Distribution: suse, redhat
Posts: 208

Rep: Reputation: 30
My bad...

I missed an escape for the + character. Try:

s/\(user[0-9]:\) \+/\1 /
or
s/\(user[0-9]:\) */\1 /
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
vim and vi editing question penguin_powered Programming 5 07-24-2005 05:43 PM
Question on editing /etc/fstab mrmcctt Linux - Software 3 10-25-2004 11:20 PM
editing .xinitrc question bosewicht Linux - Newbie 1 04-04-2004 01:58 AM
Editing the /etc/fstab question... funkenbooty Linux - Newbie 2 07-26-2003 04:49 PM
editing GRUB question walid97 Linux - General 2 10-04-2002 01:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:48 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