Thanks a lot Simon,

As I cited, the book is well described enough but I worried a bit when I saw a 
'sed' script at first time. However, as the mailing list's friends advised, 
after learning a bit online, now I don't have any trouble with 'sed' 
expressions at book :)

Here, I would like to write down what I learned just in few lines for helping 
whom reach this thread via searching the mailing list:

sed stands for 'stream editor'Streams are bytes which are traveling e.g. byte[] 
is an array but when you send it's items one by one to a destination then it's 
a stream.Linux can create a stream by |, > or < operators for example, 
following command send (save) 'Welcome to LFS' string to a file named 
welcome.txtecho 'Welcome to LFS' > welcome.txtNOTE: If you just write echo 
'Welcome to LFS' you see the message in screen but > operator direct the stream 
to a file instead.Now, sed is a powerful stream editor i.e. you can edit a 
stream on the fly and then pass it again to another destination.sed command 
line usage: write sed then write desired action in '' in front of it e.g. sed 
'action''action' is a string in a special format.
NOTE: To do two or more actions, you should use -e switch e.g. sed -e 'action1' 
-e 'action2'You ask how to write actions? while actions can do complicated jobs 
(e.g. reversing a stream) but at this time we need only following 
format:'sXregexp1Xregexp2X's stands for sub-situation,  X is sperator selected 
by you e.g. /, @, etc.This format tells sed that it should looks like for 
regular expression 1 (regexp1) and replace it with (regexp2)Example 1: echo 
'Welcome to LFS' | sed 's/LFS/LFS website/'Replaces 'LFS' with 'LFS 
website'NOTE: slash (/) has been selected to be seperatorExampl 2: echo 
'Welcome to LFS' | sed 's@[A-Z]@*&@g'A bit more complicated, right? but not at 
all when I describe it:@ has been selected to be the seperator[A-Z] means any 
uppercase letter (regular expression)
Important: & means what it finds in regexp1; In this example it will be that 
uppercase letter which have been found!g stands for global; it says to sed that 
it should replace all matches not just first oneALL IN ONE: The action says to 
sed that it should put a star before any (not just first) letter which is 
uppercase.Now, I hope you can read the book better; Could you think before that 
Linux is powerful as much as this?! Enjoy!
Sincerely Yours,
Yasser.

From: delga...@ihug.co.nz
To: lfs-support@linuxfromscratch.org
Date: Sun, 6 May 2012 20:42:03 +1200
Subject: Re: [lfs-support] Shoul I remember (keep in mind) all steps?!

On Sat, 2012-05-05 at 19:50 +0430, Yasser Zamani wrote:
> Hi there,
> 
> At first thank you very much for this useful site and book!
> 
> Currently I'm doing jobs step-by-step with no getting any errors;
> however, sometimes the steps are very specific e.g. GCC pass 2 steps.
> GCC needs that patch, fixincludes should be suppressed,
> -fomit-frame-pointer should be removed and etc. should I really
> remember and keep in mind these?! how book writer discovered these?
> because we just do steps and if we try to e.g. use another version
> then we are not sure about patches and switches, right?
 
Correct. The switches are usually fairly unchanged over time, but
patches are a mix. Some of them are fixes for bugs not yet available in
upstream releases, but others would better be described as
"configuration". For example, the GCC patches are mostly of the latter
type - they're there to change the GCC install during the process of
building the new toolchain, and aren't used in the final GCC build.
 
> One more thing; sometimes I know why to run the script but I don't
> know how script works exactly. the main example is sed. I know it
> edits streams to replace or remove something but it's command in book
> is complicated for me at this time to understand. Is it essential to
> understand how it exactly works?
 
Not essential, but the book does usually try to explain them for those
who want the details. Is there a particular example you're having
trouble with?
 
Also, if you're interested in understanding sed expressions, I'd suggest
searching for "sed one liners", and you'll see some of the more creative
examples people have come up with. It's a much more powerful tool than
most people realise...
 
Simon.

-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/lfs/faq.html
Unsubscribe: See the above information page                                     
  
-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/lfs/faq.html
Unsubscribe: See the above information page

Reply via email to