Re: [lfs-support] Shoul I remember (keep in mind) all steps?!
You're right Simon, Unicodes are two fold. And also I don't know if 'sed' can edit a binary stream :? However, in computer academic world, streams are bytes even if they are not letters e.g. 0x00 and I'm not sure why it's named 'stream editor' instead of e.g. 'tsed'(text stream editor). Actually, that expression which I mentioned is a bit complicated for who see 'sed' for first time; however, your one is almost completely unknown for me at this time :S but now, I know enugh about 'sed' to continue with LFS ;) --Yasser From: delga...@ihug.co.nz To: lfs-support@linuxfromscratch.org Date: Mon, 7 May 2012 21:00:28 +1200 Subject: Re: [lfs-support] Shoul I remember (keep in mind) all steps?! On Sun, 2012-05-06 at 21:02 +0430, Yasser Zamani wrote: 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: 1. sed stands for 'stream editor' 2. 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. Better to say characters, than bytes. They *are* bytes, of course, but as a tool for dealing with text, sed views the stream as a stream of characters. And a character isn't always a single byte. 1. Exampl 2: echo 'Welcome to LFS' | sed 's@[A-Z]@*@g' 1. A bit more complicated, right? but not at all when I describe it: Oh, that's not complicated at all. Somewhat offtopic for LFS, but try this one, used in a script I wrote for work... basically it parses and reformats the output of our version control tools... sed -n ' /version .*/h; /activity:.*@/{ H; g s/.*version \(.*\).*activity:\(.*\)@\/vobs.*/\2 - \1/ p }' 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
Re: [lfs-support] Shoul I remember (keep in mind) all steps?!
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
Re: [lfs-support] Shoul I remember (keep in mind) all steps?!
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? 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? The steps in book have been developed over time, In some cases, people very familiar with the internals have determined what the steps should be. Many are quite customized specifically for LFS. You shouldn't need to remember any steps. That's why we wrote them down for you. If you are interested in more detail, then we have been successful. You need to research switches like -fomit-frame-pointer to see what it does, but explaining the internals of gcc is quite a bit beyond LFS's goals. Learning sed, and regular expressions in general, can be challenging. It is a stream editor and will modify a text file by adding, deleting, or changing text in the file. Grabbing a sed reference and figuring out exactly what one of our seds are doing is an excellent learning exercise. -- Bruce -- http://linuxfromscratch.org/mailman/listinfo/lfs-support FAQ: http://www.linuxfromscratch.org/lfs/faq.html Unsubscribe: See the above information page
Re: [lfs-support] Shoul I remember (keep in mind) all steps?!
On Sat, 05 May 2012 16:20:45 +0100 Yasser Zamani yasser.zam...@live.com 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? Yes, just follow the book and you'll be fine. As you gain more experience and learn more you'll begin to understand more about how it all works and you'll learn (through trial and error) what you can change and what you should leave alone. 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? No, you don't need to understand. But if you're interested there are lots of good resources available online: http://sed.sourceforge.net/sed1line.txt And indeed some good old fashioned books that you could read: http://www.amazon.co.uk/Mastering-Regular-Expressions-Jeffrey-Friedl/dp/0596528124/ http://www.amazon.co.uk/sed-Nutshell-Handbooks-Dale-Dougherty/dp/1565922255/ Andy -- http://linuxfromscratch.org/mailman/listinfo/lfs-support FAQ: http://www.linuxfromscratch.org/lfs/faq.html Unsubscribe: See the above information page
Re: [lfs-support] Shoul I remember (keep in mind) all steps?!
On 05-05-2012 12:20, Yasser Zamani wrote: [...] 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. Sed is very powerful. Learning can be done by trying to understand some of the ones in LFS book, and searching the internet. Looking for sed tutorial with DuckDuckGo (or Google if you prefer): https://duckduckgo.com/?q=sed+tutorial a good list is given, the first item is very helpful: Sed - An Introduction and Tutorial - Welcome to The Grymoire! http://www.grymoire.com/Unix/Sed.html -- []s, Fernando -- http://linuxfromscratch.org/mailman/listinfo/lfs-support FAQ: http://www.linuxfromscratch.org/lfs/faq.html Unsubscribe: See the above information page