Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I've always done a global substitute like: :%s/oldstring/newstring/g. You seem to use a $ instead of %, and ? instead of /. I'm sure there must be some good reason.
Why is there a "1" at the beginning?
Could I use [a-Z] instead of [A-Za-z] ?
I suppose ^[A-Za-z] means any char at the beginning of the line, and the * means anything that follows. But I don't understand the dot.
I've always done a global substitute like: :%s/oldstring/newstring/g. You seem to use a $ instead of %, and ? instead of /. I'm sure there must be some good reason.
1,$s is the same as %s. The "1,$" just says explicitly that the substitution should be made on lines 1 to $ (last line). It's quicker just to use %.
For the separator character, you can use almost anything, not just /. I used ?. If the substitution involves a / (as in </b>), it's easier to use something other than a / so you don't have to escape it.[/quote]
Quote:
Could I use [a-Z] instead of [A-Za-z] ?
Bad idea, since you don't know what the order is. If it's ASCII, then all the caps occur before the smalls. [a-zA-Z] or [A-Za-z] is safe.
Quote:
I suppose ^[A-Za-z] means any char at the beginning of the line, and the * means anything that follows. But I don't understand the dot.
dot means any character except newline. * means 0 or more. So, .* means "everything up to the end of the line".
By the way, the ampersand (&) means "the thing that was matched". Also take a look at what homey did.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.