LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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


Reply
  Search this Thread
Old 01-13-2021, 03:43 PM   #1
NuttyJamie
LQ Newbie
 
Registered: Nov 2020
Location: South Korea
Distribution: Linuxfromscratch, Slackware 15
Posts: 20

Rep: Reputation: 0
What does '/m64=/' mean in the sed command?


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.
 
Old 01-13-2021, 03:53 PM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by NuttyJamie View Post
Code:
sed -e '/m64=/s/lib64/lib/' \
What exactly does the /m64=/ do?
It selects the lines that sed will process. In this case, the substitution is performed in all lines that contain "m64=".
Quote:
I searched through several sed tutorials and found nothing similar.
See https://www.gnu.org/software/sed/man...esses-overview.

Last edited by berndbausch; 01-13-2021 at 03:56 PM.
 
1 members found this post helpful.
Old 01-13-2021, 04:22 PM   #3
NuttyJamie
LQ Newbie
 
Registered: Nov 2020
Location: South Korea
Distribution: Linuxfromscratch, Slackware 15
Posts: 20

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by berndbausch View Post
It selects the lines that sed will process. In this case, the substitution is performed in all lines that contain "m64=".
Oh, Now it seems clear. I thought it was a sed's own option or sub-command or similar to regular expression... what a stupid.
Quote:
Originally Posted by berndbausch View Post
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.
 
Old 01-13-2021, 05:36 PM   #4
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by NuttyJamie View Post
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.
 
Old 01-13-2021, 06:27 PM   #5
NuttyJamie
LQ Newbie
 
Registered: Nov 2020
Location: South Korea
Distribution: Linuxfromscratch, Slackware 15
Posts: 20

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by berndbausch View Post
All GNU software is documented.
That's just awesome!
I am happy because there are many documents to study.
Quote:
In my opinion, the sed manual is fairly well-written.
I totally agree.
 
Old 01-14-2021, 01:53 PM   #6
tofino_surfer
Member
 
Registered: Aug 2007
Posts: 483

Rep: Reputation: 153Reputation: 153
Quote:
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=/.
 
1 members found this post helpful.
  


Reply

Tags
sed



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] STRANGE: Newly Compiled GCC 4.4.4 on Solaris sparc gives problem with -m32/-m64 flags d_shanke Solaris / OpenSolaris 3 08-09-2012 05:31 PM
STRANGE: Newly Compiled GCC 4.4.4 on Solaris sparc gives problem with -m32/-m64 flags d_shanke Linux - Newbie 1 07-30-2012 09:52 AM
[SOLVED] GCC options: (-m64) vs (-march=native) vs (-march=core2) -- Which one(s) to use? GrapefruiTgirl Linux - Software 5 09-29-2009 07:53 AM
nvidia tnt2 m64 problems travm Linux - Hardware 1 02-01-2007 08:53 PM
Mandrake 8.1 and Nvidia TnT m64 caphead Linux - Software 11 12-08-2001 05:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:25 AM.

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