IRC log of #novawebdev for Monday, 2023-10-09

*** shmohamud has quit (Remote host closed the connection)01:25
svayeGood morning Jeff10:53
fkoikoiGood Morning Jeff10:56
scooperGood morning everyone11:08
svayeGood morning scooper we are in the accict chat 11:09
scooperI m there already11:09
svayeokay11: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
mulbahGood morning Mr. Cole13:02
ubuntouristHi mulbah 13:02
mulbahHow are you doing13:02
mulbahthis morning13:03
ubuntouristI'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
ubuntouristHow are you?13:03
mulbahI'm good it's just that I'm thinking on our election that is about to go on tomorrow13:04
ubuntouristI should try to follow more world politics. Our elections here are becoming crazier. What's happening with your elections?13:05
mulbahwell the election here is tuft 13:07
mulbaheveryone is afraid be of the tilting word the two top party are using13:09
mulbahone say that if the other one win they will bring war 13:10
mulbahbut we are praying for peaceful election13:11
ubuntouristI 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
ubuntouristAs for your situation, that would keep me awake at night, worrying about tomorrow.13:12
ubuntouristHow quickly are the results tallied? Will people know the situation by tomorrow evening? Or is the counting and recounting13:13
ubuntouristof votes a slow process after the election?13:13
mulbahno it not slow13:18
mulbahno it's not slow13:18
ubuntouristI 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, unlike13:20
ubuntouristanything we have seen before. There has been a serious erosion of faith in our news, our courts, and our legislators.13:21
ubuntouristWell, I wish for a peaceful for you and will keep up with the news, at least for a few days.13:22
ubuntouristSo... on to computer topics. 13:23
mulbahAlright13:23
ubuntouristFirst, any questions or ideas that you want to explore?13:23
ubuntouristls13:24
ubuntourist(oops. wrong window.)13:24
mulbahno question Mr. Cole13:24
ubuntouristOK.13:26
ubuntouristssh TA7wBGFnDQazefZc7utGEZWcn@lon1.tmate.io13:26
ubuntouristSo.  We're looking at the bottom of the README to finish going through that example...13:28
ubuntouristLast time, I said that you could take a series of commands that are joined by pipes,13:29
ubuntouristand create an interator from the results.13:30
ubuntouristEnclosing 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 backslash13: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
ubuntouristis the same as $(locate ly | grep "\.ly$"13:35
ubuntouristSo tie iterator here a list that is generated by $(locate ly | grep "\.ly$" | grep kjcole | egrep -v "....")13:36
ubuntouristi just split it across several lines to try  to make it more readable.13:36
ubuntouristThe Bash environment variable "filename" is just a variable. I could have said "for x" instead of "for filename".13:37
ubuntouristThis will fetch, one by one, the lines from the output of the piped commands: 13:38
ubuntouristA list of file names with their full path -- for example, /home/kjcole/.../.../.../something.ly -- and use the file name in13:40
ubuntouristthe rest of the code.13:40
ubuntouristThe first line inside of the for loop (ignoring "do" and "done") is:13:41
ubuntouristegrep -H "^[[:space:]]*(poet|composer|arranger)" $filename 13:41
ubuntouristWe'll talk about the -H in a minute. The rest of the "extended" grep (egrep) first.13:42
ubuntouristThe 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 by13: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
ubuntouristNormally if you search a file and there are no matches, there is no output.13:47
ubuntouristACTION 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 that13:49
ubuntouristis 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
ubuntouristHod on... I just got an alarm on my computer... I think I have a dentist appointment in 10 minutes!!!13:51
mulbahokay13:52
ubuntouristWell. I did have a dentist appointment. I screwed up. But I just called and they can postpone it until later today.13:55
ubuntouristBut I also need to take my medication. Two minute break.13:55
mulbahAlright13:56
ubuntouristBacck again.13:57
ubuntouristSo. we can see that the file README.md does not have any match for "qwert"13:57
ubuntouristAlso, if you are only searching one file, when a match is found, the file name is not printed. Watch in the terminal.13:58
ubuntouristIt printed all the lines with the string "poet" but it did not show the file name.13:59
ubuntouristThis is what the "-H" adds.13:59
ubuntouristNow the matches are prefixed with the file name.14:00
ubuntouristAnother useful option is "-c" for "count" -- Instead of showing the filename and the matches, it will14:01
ubuntouristshow the file name and the count of matches...14:01
ubuntouristzero matches for "qwert"14:01
mulbahit work almost like the wc -l command14:01
ubuntouristYeah.14:02
ubuntouristSo, 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
ubuntouristFifteen matches for "poet" in the file.14:03
ubuntouristback to the Bash program....14:04
ubuntouristSo... when the "egrep -H ... $filename" finds a match it will output something like:14:05
ubuntouristsong_of_joy.ly:     poet14:06
ubuntouristsong_of_joy.ly:    composer = "J.S. Bach"14:06
ubuntouristsong_of_joy.ly:    arranger = "Unknown"14:07
ubuntourist...14:07
ubuntouristIt found three matching lines in my imaginary file "song_of_joy.ly" Remember: We're only searching14:08
ubuntouristin files that are owned by me, ending in ".ly" and eliminating some directories that I do not want to search.14:08
ubuntouristNow, we take the result of the search -- the three lines that match and pipe them into 14:09
ubuntourist"grep -v "smallCaps"14:09
ubuntouristThat means IF the line did have "smallCaps" it would be eliminated from the search. In other words, if 14:10
ubuntouristthe match for the egrep -H was:14:10
ubuntouristsong_of_joy.ly:    poet14:11
ubuntouristsong_of_joy.ly:    composer = \markup { \ smallCaps "J.S. Bach" }14:11
ubuntouristsong_of_joy.ly:    composer = "Unknown"14:12
ubuntouristthe 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
ubuntouristdo not need to edit the file: I already took care of the problem. But if I have any14:14
ubuntouristpoet, composer or arranger lines that do not have "\smallCaps" then I want to get those files for editing.14:14
ubuntouristSo, next: cut14:15
ubuntouristright now, we have eliminated the middle line, so we have:14:15
ubuntouristsong_of_joy.ly:    poet14:15
ubuntouristsong_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
ubuntouristAnyway, "cut" lets you remove parts of a line. I think we looked at this a little bit before.14:18
ubuntouristYo can tell cut to remove the any number of characters, or any number of "fields".14:19
ubuntouristNow I remember: We did look at cut when we were looking at the "/etc/passwd" file.14:19
ubuntouristI'm just creating a simple example here about "cut". So I am using a line from the file that has a match for14:21
ubuntouriststarting at the beginning of a line, two characters followed by "To be continued".14:22
ubuntouristNow 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
ubuntouristSo that's what it printed.14:24
ubuntouristYou 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 to14:25
ubuntouristthe 6th byte.14:25
ubuntouristIf I said "7-" it means from the 7th byte to the end of the line.14:25
ubuntouristFollowing okay?14:26
mulbahyeah14:26
ubuntouristYou can also do something similar with "fields". Fields are groups of characters separated by some common14:27
ubuntourist"delimiter". The delimiter can be any single character you want. So, in this example the obvious delimiter would be14:28
ubuntourista space. Spaces break the line into logical "fileds" which we would noramlly just call "words".14:29
ubuntouristcutting fields is the same as cutting bytes but you must tell it what the delimiter is.14:29
ubuntouristOh, 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 then14:32
ubuntouristthe tenth through fifteenth characters. We did not grab characters seven, eight and nine ".ly"14:32
ubuntouristBack to fields.14:33
ubuntouristI tokd it that the delimiter was the space character, by using -d " "14:34
ubuntouristthen 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
ubuntouristWhen you use the field option the delimiter is never printed. It is considered to be an invisible divider in the line.14:38
ubuntouristHow would you use cut to print only "README.md" from the output "README.md:* To be continued..."14:39
ubuntouristACTION needs a bathroom break while you think about that.14:39
ubuntouristACTION is back and waiting for your thoughts.14:44
mulbahegrep -H "^..To be continued" README.md | cut -b 1-14:44
ubuntouristTry it.14:44
mulbahcorrect right?14:45
ubuntouristNope. 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
mulbahegrep -H "^..To be contin14:48
mulbahued" README.md | cut -b 1-914:48
ubuntouristYep. 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
ubuntouristExplain back to me what a field is and what a delimiter is.14:52
ubuntouristOh... maybe you've got it... continue with your current experiment...14:52
mulbahA delimiter can be any single character you want14:53
ubuntouristSo. Try a different character and see what happens.14:54
ubuntouristYou used a space. That's what we've been using before. Try a different character.14:55
mulbahwhat do you mean by I should use a different character14:57
ubuntouristWhat 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
ubuntouristYou only need to change one character  in         - d " "      15:01
ubuntouristIf this were Python and you saw the line15:02
ubuntouristpriint("hello")15:02
ubuntouristand I said "change one character so that it spells the word wrong, what would you do?15:03
mulbahI could say print("Helol")15:04
ubuntouristSo. 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
mulbahprint("Me")15:06
ubuntouristThat's two characters. I only want one.15:06
mulbahprint("7")15:07
ubuntouristSo. 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
ubuntouristOK! 15:08
ubuntouristSo. Stop a minute.15:09
ubuntouristWhat did that tell you?15:09
mulbahwhat do you mean15:09
ubuntouristWhen 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
ubuntouristWe used space. So, it broke the line into fields wherever a space occurred. The space character was the seperator.15:11
ubuntouristNow, you used  9 as your delimiter for the line "README.md:* To be continued..." Why did it print the whole line?15:11
mulbahI 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
ubuntouristI really want you to understand this on your own. When you say you have no questions, it means you understood and tried15:18
ubuntouristwhat we talked about. Go back to your notes from several weeks ago, when we were talking about file ownership15:18
ubuntouristand file permission and we looked at "/etc/passwd" fields. And we used the cut command. And you said you had no questions.15:19
ubuntouristI need to get ready to leave for my dentist appointment. So, we will talk about this on Friday or you can send15:20
ubuntouristemail -- not Zulip about it.15:21
ubuntouristbye 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/!