*** shmohamud has quit (Remote host closed the connection) | 01:25 | |
svaye | Good morning Jeff | 10:53 |
---|---|---|
fkoikoi | Good Morning Jeff | 10:56 |
scooper | Good morning everyone | 11:08 |
svaye | Good morning scooper we are in the accict chat | 11:09 |
scooper | I m there already | 11:09 |
svaye | okay | 11:09 |
*** sysadmin has quit (Remote host closed the connection) | 11:33 | |
*** scooper has quit (Ping timeout: 480 seconds) | 11:38 | |
*** jelkner has quit (Quit: Leaving) | 11:57 | |
*** svaye has quit (Quit: Leaving) | 11:58 | |
*** fkoikoi has quit (Quit: Leaving) | 11:58 | |
mulbah | Good morning Mr. Cole | 13:02 |
ubuntourist | Hi mulbah | 13:02 |
mulbah | How are you doing | 13:02 |
mulbah | this morning | 13:03 |
ubuntourist | I'm well. Still taking medication but the infection is gone. (Doctors always say "Don't stop taking the antibiotics until the bottle is empty.") | 13:03 |
ubuntourist | How are you? | 13:03 |
mulbah | I'm good it's just that I'm thinking on our election that is about to go on tomorrow | 13:04 |
ubuntourist | I should try to follow more world politics. Our elections here are becoming crazier. What's happening with your elections? | 13:05 |
mulbah | well the election here is tuft | 13:07 |
mulbah | everyone is afraid be of the tilting word the two top party are using | 13:09 |
mulbah | one say that if the other one win they will bring war | 13:10 |
mulbah | but we are praying for peaceful election | 13:11 |
ubuntourist | I am trying to obtain Irish citizenship partially because I really like the culture but partially because I want to have a place to flee to before 2024. | 13:11 |
ubuntourist | As for your situation, that would keep me awake at night, worrying about tomorrow. | 13:12 |
ubuntourist | How quickly are the results tallied? Will people know the situation by tomorrow evening? Or is the counting and recounting | 13:13 |
ubuntourist | of votes a slow process after the election? | 13:13 |
mulbah | no it not slow | 13:18 |
mulbah | no it's not slow | 13:18 |
ubuntourist | I do not think we will have a full-blown civil war but I feel there will be violent riots and civil unrest after the 2024 elections, unlike | 13:20 |
ubuntourist | anything we have seen before. There has been a serious erosion of faith in our news, our courts, and our legislators. | 13:21 |
ubuntourist | Well, I wish for a peaceful for you and will keep up with the news, at least for a few days. | 13:22 |
ubuntourist | So... on to computer topics. | 13:23 |
mulbah | Alright | 13:23 |
ubuntourist | First, any questions or ideas that you want to explore? | 13:23 |
ubuntourist | ls | 13:24 |
ubuntourist | (oops. wrong window.) | 13:24 |
mulbah | no question Mr. Cole | 13:24 |
ubuntourist | OK. | 13:26 |
ubuntourist | ssh TA7wBGFnDQazefZc7utGEZWcn@lon1.tmate.io | 13:26 |
ubuntourist | So. We're looking at the bottom of the README to finish going through that example... | 13:28 |
ubuntourist | Last time, I said that you could take a series of commands that are joined by pipes, | 13:29 |
ubuntourist | and create an interator from the results. | 13:30 |
ubuntourist | Enclosing the piped commands inside of "$(" and ")" creates an iterator from the output. | 13:31 |
ubuntourist | (In Bash programs, if you have a long command, you can "wrap" the command onto multiple lines by ending the line with a backslash | 13:33 |
ubuntourist | "\". But you cannot put the backslash inside of a quoted string. So the "egrep" in the script cannot be broken into multiple lines.) | 13:34 |
ubuntourist | $(locate ly | \ | 13:34 |
ubuntourist | grep "\.ly$" | 13:34 |
ubuntourist | is the same as $(locate ly | grep "\.ly$" | 13:35 |
ubuntourist | So tie iterator here a list that is generated by $(locate ly | grep "\.ly$" | grep kjcole | egrep -v "....") | 13:36 |
ubuntourist | i just split it across several lines to try to make it more readable. | 13:36 |
ubuntourist | The Bash environment variable "filename" is just a variable. I could have said "for x" instead of "for filename". | 13:37 |
ubuntourist | This will fetch, one by one, the lines from the output of the piped commands: | 13:38 |
ubuntourist | A list of file names with their full path -- for example, /home/kjcole/.../.../.../something.ly -- and use the file name in | 13:40 |
ubuntourist | the rest of the code. | 13:40 |
ubuntourist | The first line inside of the for loop (ignoring "do" and "done") is: | 13:41 |
ubuntourist | egrep -H "^[[:space:]]*(poet|composer|arranger)" $filename | 13:41 |
ubuntourist | We'll talk about the -H in a minute. The rest of the "extended" grep (egrep) first. | 13:42 |
ubuntourist | The regular expression "^[[:space:]]*(poet|composer|arranger)" breaks apart like this: | 13:42 |
ubuntourist | ^ lines that begin with.... | 13:43 |
ubuntourist | [[:space:]]* zero or more "whitespace" characters, including SPACE or TAB followed by | 13:44 |
ubuntourist | (poet|composer|arranger) any of the three strings "poet" or "composer" or "arranger" | 13:45 |
ubuntourist | $filename -- Only search for the matches in whichever file is currently being fetched from the iterator list. | 13:46 |
ubuntourist | Normally if you search a file and there are no matches, there is no output. | 13:47 |
ubuntourist | ACTION switches over to the terminal... | 13:47 |
ubuntourist | "qwert" is my favorite silly word: I use it when I want to create a temprary file name or variable name or something that | 13:49 |
ubuntourist | is almost never matched with anything. It is a meaningless "dummy" word that is just the first five letters to the right of theTAB key. | 13:50 |
ubuntourist | Hod on... I just got an alarm on my computer... I think I have a dentist appointment in 10 minutes!!! | 13:51 |
mulbah | okay | 13:52 |
ubuntourist | Well. I did have a dentist appointment. I screwed up. But I just called and they can postpone it until later today. | 13:55 |
ubuntourist | But I also need to take my medication. Two minute break. | 13:55 |
mulbah | Alright | 13:56 |
ubuntourist | Bacck again. | 13:57 |
ubuntourist | So. we can see that the file README.md does not have any match for "qwert" | 13:57 |
ubuntourist | Also, if you are only searching one file, when a match is found, the file name is not printed. Watch in the terminal. | 13:58 |
ubuntourist | It printed all the lines with the string "poet" but it did not show the file name. | 13:59 |
ubuntourist | This is what the "-H" adds. | 13:59 |
ubuntourist | Now the matches are prefixed with the file name. | 14:00 |
ubuntourist | Another useful option is "-c" for "count" -- Instead of showing the filename and the matches, it will | 14:01 |
ubuntourist | show the file name and the count of matches... | 14:01 |
ubuntourist | zero matches for "qwert" | 14:01 |
mulbah | it work almost like the wc -l command | 14:01 |
ubuntourist | Yeah. | 14:02 |
ubuntourist | So, the "-Hc" is the same as typing "-H -c" (or "-c -H". The order makes no difference.) Force the file name to be printed and show the count, | 14:03 |
ubuntourist | Fifteen matches for "poet" in the file. | 14:03 |
ubuntourist | back to the Bash program.... | 14:04 |
ubuntourist | So... when the "egrep -H ... $filename" finds a match it will output something like: | 14:05 |
ubuntourist | song_of_joy.ly: poet | 14:06 |
ubuntourist | song_of_joy.ly: composer = "J.S. Bach" | 14:06 |
ubuntourist | song_of_joy.ly: arranger = "Unknown" | 14:07 |
ubuntourist | ... | 14:07 |
ubuntourist | It found three matching lines in my imaginary file "song_of_joy.ly" Remember: We're only searching | 14:08 |
ubuntourist | in files that are owned by me, ending in ".ly" and eliminating some directories that I do not want to search. | 14:08 |
ubuntourist | Now, we take the result of the search -- the three lines that match and pipe them into | 14:09 |
ubuntourist | "grep -v "smallCaps" | 14:09 |
ubuntourist | That means IF the line did have "smallCaps" it would be eliminated from the search. In other words, if | 14:10 |
ubuntourist | the match for the egrep -H was: | 14:10 |
ubuntourist | song_of_joy.ly: poet | 14:11 |
ubuntourist | song_of_joy.ly: composer = \markup { \ smallCaps "J.S. Bach" } | 14:11 |
ubuntourist | song_of_joy.ly: composer = "Unknown" | 14:12 |
ubuntourist | the grep -v "smallCaps" would eliminate the middle match and only two lines would be output. | 14:13 |
ubuntourist | (I want to find all of my LilyPond (*.ly) files where I forgot to add "\smallCaps". If the file already has that, I | 14:13 |
ubuntourist | do not need to edit the file: I already took care of the problem. But if I have any | 14:14 |
ubuntourist | poet, composer or arranger lines that do not have "\smallCaps" then I want to get those files for editing. | 14:14 |
ubuntourist | So, next: cut | 14:15 |
ubuntourist | right now, we have eliminated the middle line, so we have: | 14:15 |
ubuntourist | song_of_joy.ly: poet | 14:15 |
ubuntourist | song_of_joy.ly: arranger = "Unknown" | 14:16 |
ubuntourist | (My mistake above: In my example I'm always intending to show arranger = "Unknown" not composer = "Unknown") | 14:17 |
ubuntourist | Anyway, "cut" lets you remove parts of a line. I think we looked at this a little bit before. | 14:18 |
ubuntourist | Yo can tell cut to remove the any number of characters, or any number of "fields". | 14:19 |
ubuntourist | Now I remember: We did look at cut when we were looking at the "/etc/passwd" file. | 14:19 |
ubuntourist | I'm just creating a simple example here about "cut". So I am using a line from the file that has a match for | 14:21 |
ubuntourist | starting at the beginning of a line, two characters followed by "To be continued". | 14:22 |
ubuntourist | Now we're going to chop it up with cut. | 14:22 |
ubuntourist | "-b" is for "bytes" which is usually synonymous with "characters" and 1-6 means "from the first byte to the sixth byte" | 14:24 |
ubuntourist | So that's what it printed. | 14:24 |
ubuntourist | You can also leave off one of the numbers. So if I said "-6" without the "1" it means "from the beginning of the line up to | 14:25 |
ubuntourist | the 6th byte. | 14:25 |
ubuntourist | If I said "7-" it means from the 7th byte to the end of the line. | 14:25 |
ubuntourist | Following okay? | 14:26 |
mulbah | yeah | 14:26 |
ubuntourist | You can also do something similar with "fields". Fields are groups of characters separated by some common | 14:27 |
ubuntourist | "delimiter". The delimiter can be any single character you want. So, in this example the obvious delimiter would be | 14:28 |
ubuntourist | a space. Spaces break the line into logical "fileds" which we would noramlly just call "words". | 14:29 |
ubuntourist | cutting fields is the same as cutting bytes but you must tell it what the delimiter is. | 14:29 |
ubuntourist | Oh, I forgot: With both bytes and fields you can have a list, using commas. Let me show that first. | 14:30 |
ubuntourist | "README.md:* To be continued..." became "README:* To" because we grabbed the first six charaters, and then | 14:32 |
ubuntourist | the tenth through fifteenth characters. We did not grab characters seven, eight and nine ".ly" | 14:32 |
ubuntourist | Back to fields. | 14:33 |
ubuntourist | I tokd it that the delimiter was the space character, by using -d " " | 14:34 |
ubuntourist | then I told it to print field 1 and then field 2, field 3 and field 4. It broke the line where the spaces occurred. | 14:35 |
ubuntourist | When you use the field option the delimiter is never printed. It is considered to be an invisible divider in the line. | 14:38 |
ubuntourist | How would you use cut to print only "README.md" from the output "README.md:* To be continued..." | 14:39 |
ubuntourist | ACTION needs a bathroom break while you think about that. | 14:39 |
ubuntourist | ACTION is back and waiting for your thoughts. | 14:44 |
mulbah | egrep -H "^..To be continued" README.md | cut -b 1- | 14:44 |
ubuntourist | Try it. | 14:44 |
mulbah | correct right? | 14:45 |
ubuntourist | Nope. I only want to see "README.md" printed. Not the rest of the line. | 14:46 |
ubuntourist | (When you are experimenting with this, only change the cut. Don't change the egrep.) | 14:47 |
mulbah | egrep -H "^..To be contin | 14:48 |
mulbah | ued" README.md | cut -b 1-9 | 14:48 |
ubuntourist | Yep. That's one way to do it. Can you see a way to do it with the "-f"? Is there a way to think about the line as fields but with a different delimiter? | 14:49 |
ubuntourist | Explain back to me what a field is and what a delimiter is. | 14:52 |
ubuntourist | Oh... maybe you've got it... continue with your current experiment... | 14:52 |
mulbah | A delimiter can be any single character you want | 14:53 |
ubuntourist | So. Try a different character and see what happens. | 14:54 |
ubuntourist | You used a space. That's what we've been using before. Try a different character. | 14:55 |
mulbah | what do you mean by I should use a different character | 14:57 |
ubuntourist | What part of commmand had a space for the delimiter? Replace the space. Not the other parts of the command. | 14:58 |
ubuntourist | -d " " means "I wan t to use a space as a delimiter." Where is the space in that? Replace only that part. | 15:00 |
ubuntourist | You only need to change one character in - d " " | 15:01 |
ubuntourist | If this were Python and you saw the line | 15:02 |
ubuntourist | priint("hello") | 15:02 |
ubuntourist | and I said "change one character so that it spells the word wrong, what would you do? | 15:03 |
mulbah | I could say print("Helol") | 15:04 |
ubuntourist | So. If I say change one character in -d " " so that it uses a different delimiter characcter, what would you do? | 15:04 |
ubuntourist | (If you had a line in Python print(" ") I said change it so that it prints a different character, whart would you do? | 15:05 |
mulbah | print("Me") | 15:06 |
ubuntourist | That's two characters. I only want one. | 15:06 |
mulbah | print("7") | 15:07 |
ubuntourist | So. Again if you saw -d " " and I said change it so that it uses a delimiter that is not a space... | 15:07 |
mulbah | -d "5" | 15:08 |
ubuntourist | OK! | 15:08 |
ubuntourist | So. Stop a minute. | 15:09 |
ubuntourist | What did that tell you? | 15:09 |
mulbah | what do you mean | 15:09 |
ubuntourist | When I said a delimiter can be any character you want, I meant "You can separate a line into fields by picking a character in the line and using that character to break the line apart." | 15:10 |
ubuntourist | We used space. So, it broke the line into fields wherever a space occurred. The space character was the seperator. | 15:11 |
ubuntourist | Now, you used 9 as your delimiter for the line "README.md:* To be continued..." Why did it print the whole line? | 15:11 |
mulbah | I think because it print the line | 15:13 |
ubuntourist | (You should be able to reconnect with the same ssh. So just press the up arrow to find the ssh command.) | 15:15 |
ubuntourist | I really want you to understand this on your own. When you say you have no questions, it means you understood and tried | 15:18 |
ubuntourist | what we talked about. Go back to your notes from several weeks ago, when we were talking about file ownership | 15:18 |
ubuntourist | and file permission and we looked at "/etc/passwd" fields. And we used the cut command. And you said you had no questions. | 15:19 |
ubuntourist | I need to get ready to leave for my dentist appointment. So, we will talk about this on Friday or you can send | 15:20 |
ubuntourist | email -- not Zulip about it. | 15:21 |
ubuntourist | bye for today... | 15:21 |
*** ubuntourist has quit (Quit: Leaving) | 15:21 | |
*** mulbah has quit (Ping timeout: 480 seconds) | 15:21 | |
*** mulbah has quit (Ping timeout: 480 seconds) | 16:50 | |
*** scooper has quit (None) | 17:16 | |
*** sysadmin has quit (Ping timeout: 480 seconds) | 17:57 | |
*** mulbah07_ has quit (Remote host closed the connection) | 18:06 |
Generated by irclog2html.py 2.17.3 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!