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 |
Re: Editing Question...
Quote:
|
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 |
Thanks for the reply, when i run :s/\(user[0-9]:\) +/\1 /
from vi, I get an error "substitution failed" any ideas? |
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. |
Sorry was a typo on my post, the command still does not work.
|
My bad...
I missed an escape for the + character. Try: s/\(user[0-9]:\) \+/\1 / or s/\(user[0-9]:\) */\1 / |
All times are GMT -5. The time now is 07:52 AM. |