[SOLVED] What does '/m64=/' mean in the sed command?
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.
Greetings folks!
I saw this type of sed command while following the LinuxFromScratch book's instructions.
First, the book says:
Quote:
If building on x86_64, change the default directory name for 64-bit libraries to “lib”:
And the code is:
Code:
case $(uname -m) in
x86_64)
sed -e '/m64=/s/lib64/lib/' \
-i.orig gcc/config/i386/t-linux64
;;
esac
I knew sed's replace command format, such as s/<source text>/<replace text>/gc, and so I know what this whole code ends up doing, but I've never seen the middle part of it before.
Code:
sed -e '/m64=/s/lib64/lib/' \
What exactly does the /m64=/ do?
I searched through several sed tutorials and found nothing similar.
The GNU manual! Why didn't I think of that?
I just saw it for the first time and it's very detailed and useful. Not only solved a problem, but I also learned that there was a manual written by FSF.
It was a lot of help. Thank you very much.
I just saw it for the first time and it's very detailed and useful. Not only solved a problem, but I also learned that there was a manual written by FSF.
All GNU software is documented. In my opinion, the sed manual is fairly well-written.
I searched through several sed tutorials and found nothing similar.
It's in the sed manpage itself under the section "Addresses"
Code:
Addresses
Sed commands can be given with no addresses, in which case the command will be executed for all input lines; with one address, in which case the command will only be exe‐
cuted for input lines which match that address; or with two addresses, in which case the command will be executed for all input lines which match the inclusive range of
lines starting from the first address and continuing to the second address. Three things to note about address ranges: the syntax is addr1,addr2 (i.e., the addresses are
separated by a comma); the line which addr1 matched will always be accepted, even if addr2 selects an earlier line; and if addr2 is a regexp, it will not be tested against
the line that addr1 matched.
...
/regexp/
Match lines matching the regular expression regexp. Matching is performed on the current pattern space, which can be modified with commands such as ``s///''.
So therefore sed -e 's/lib64/lib/' has no address and the s// operates on all input lines.
Conversely sed -e '/m64=/s/lib64/lib/' has a regular expression address of /m64=/ so the s// construct only works on lines matching /m64=/.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.