LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-14-2018, 11:12 PM   #1
whjeon
Member
 
Registered: Feb 2018
Location: Seoul,South Korea
Distribution: Debian
Posts: 88

Rep: Reputation: Disabled
sed command question


Dear mentors

I have one question.
What does '@' mean, in command below
sed -e 's@/lib/ ~blahblah

Thanks for your help!
 
Old 03-15-2018, 12:09 AM   #2
BudiKusasi
Member
 
Registered: Apr 2017
Distribution: Artix
Posts: 345

Rep: Reputation: 15
you just looked at a typo typed by someone, nothing such in sed
 
Old 03-15-2018, 12:37 AM   #3
whjeon
Member
 
Registered: Feb 2018
Location: Seoul,South Korea
Distribution: Debian
Posts: 88

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by BudiKusasi View Post
you just looked at a typo typed by someone, nothing such in sed
Thanks for your reply, but that's no way! That command was from LFS book.
I'll attach exact command this time.

sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
-e 's@/usr@/tools@g' $file.orig > $file
(If it shows 'won currency', that's because I live in Korea. that's all convertible with 'backslash'
 
Old 03-15-2018, 12:47 AM   #4
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,150

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
You must look into $file.orig what's inside there.

Here's a link from G search: https://stackoverflow.com/questions/...omplex-replace
 
Old 03-15-2018, 12:53 AM   #5
BudiKusasi
Member
 
Registered: Apr 2017
Distribution: Artix
Posts: 345

Rep: Reputation: 15
This is Linux stable-tested forum not LFS which could be different in the local character interpretations, find a place for proper LFS forum

Last edited by BudiKusasi; 03-15-2018 at 12:56 AM.
 
Old 03-15-2018, 12:54 AM   #6
whjeon
Member
 
Registered: Feb 2018
Location: Seoul,South Korea
Distribution: Debian
Posts: 88

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by BudiKusasi View Post
This is Linux stable-tested forum not LFS which could be different in the local character intepretation, find a place for proper LFS forum
OK! Thanks for your help. I thought it would be a 'sed command's feature or REGEX thing.
Thanks again
 
Old 03-15-2018, 01:07 AM   #7
BudiKusasi
Member
 
Registered: Apr 2017
Distribution: Artix
Posts: 345

Rep: Reputation: 15
@JJJCR.. thanks..
now just remember that follows the command must be a separator
@whjeon.. sorry for incorrect reply
s is a command and whatever immediately follows it is a regex-replcement separator character.

so regex is
Code:
/lib\(64\)\?\(32\)\?/ld
and replacement
Code:
/tools&
and option
Code:
g

Last edited by BudiKusasi; 03-15-2018 at 02:32 AM.
 
Old 03-15-2018, 02:02 AM   #8
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,792

Rep: Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201
Yes, the character following the s command becomes the separator.
Usually one takes the / but here it conflicts with the / in the regexp and substitution strings.
I think that # would look nicer than @
Code:
sed -e 's#/lib\(64\)\?\(32\)\?/ld#/tools&#g' \
 -e 's#/usr#/tools#g' $file.orig > $file
The & in the substitution string means "all that matched".
I think they mean lib optionally followed by either 64 or 32, so the following is more correct
Code:
sed -r -e 's#/lib(64|32)?/ld#/tools&#g' \
 -e 's#/usr#/tools#g' $file.orig > $file
 
Old 03-15-2018, 02:06 AM   #9
whjeon
Member
 
Registered: Feb 2018
Location: Seoul,South Korea
Distribution: Debian
Posts: 88

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by MadeInGermany View Post
Yes, the character following the s command becomes the separator.
Usually one takes the / but here it conflicts with the / in the regexp and substitution strings.
I think that # would look nicer than @
Thanks! Now I understand what it meant.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about sed command. xeon123 Linux - Newbie 3 03-02-2012 12:38 PM
[SOLVED] Question about sed command rbalaa Linux - Software 11 11-25-2011 10:07 AM
[Solved] Problem - question for command inside sed. logar0 Linux - Newbie 10 10-25-2010 11:41 AM
sed command question mokku Linux - Newbie 2 03-05-2008 11:30 AM
question about using sed command feetyouwell Linux - Software 4 12-13-2004 08:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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