You are on page 1of 3

let me ask you a question that you might actually get at a technical interview uh

not this specific question but maybe something along the lines of i have a file and
it has multiple lines and each line has this specific word that occurs multiple
times how would you go about replacing only the second or the nth occurrence of the
word second third fourth whatever it is if you asked me this a couple of months ago
i probably would have said something along the lines of i would create a console
application that would parse the content of the file and then manipulate it that
way but now after discovering the power of the command line i would say that i
would use the stream editor command or the sed command or the sed command some the
thing about linux is everything has like multiple pronunciations and they're all
correct somehow like butter fs or better file system or better fs yeah um i'll show
you how to use that command and to accomplish that task at the end of this video
with that being said hi i'm gps and welcome to a new video let me start with the
why like most of us we learn things because it'll make us better at work or it's
required for work or whatever work you know let's just say work i knew when i
started my role at acg i was going to be working on linux related projects and i
simply didn't feel comfortable enough with my at that time skill set of linux to
work on any of the projects so sat down with my manager and we flushed it out and i
decided that i'm going to take a certification within a certain amount of time the
first attempt at certification i actually failed i made a video on that um and then
i took it a second time and i passed i always felt reluctant to learn linux because
for some reason out of everything in tech it's that one space where i feel like i
definitely don't belong i don't know why it is maybe it's because of my lack of
experience or i don't know the right tools or or i'm not sure what it is and now
that i've actually dipped my toes in in the space i've realized that it's a foolish
mindset to have um i'm quite intrigued and slightly in a healthy way obsessed with
uh the linux and and i actually have popo s which is an ubuntu base distribution on
my desktop and i've been using it as my main operating system for a couple of weeks
now and i know people are going to hop in the comments now and say you should be
using this distro or you should be using that distro hey i'm going to give a bunch
of distros a try just not right now i'm trying to just get comfortable right now
but yeah in this open source space and me having the mission to make you know
technology and technical education more accessible and less daunting to everyone
becoming more familiar and learning about things like linux and open source seems
right up my alley so i'm glad i'm doing it now let me talk about the how i have no
shame in saying that when i'm learning something new i need a variety and lots of
learning material and that's videos that's text that could be like books or i don't
know some documentation and obviously hands-on disclaimer as most of you probably
know by now i work at a club guru so that means i have full access to our entire
catalog and we have multiple linux courses so that helped me a lot i watched the
linux essentials course and the lpi 101 which is sort of a step above it but what i
like is that i can grab some kind of lesson and if i need like another type of
explanation or i want to watch a different explanation on it i can go to another
course and see if it covers that topic sometimes with certifications they have
overlap and you know topics will be covered in both of them but they might be
explained in different ways or different contexts so i like that in terms of books
i have two this one is the command line well the linux command line it's sort of
like every command well not every but the majority of commands that you could
possibly need to use is probably in this book and what's great about it is it gives
you the explanation and it gives you like most popular arguments that you could use
and it also gives you kind of like a an exercise to do or like a playground
exercise i think that's what they call it yeah so i just go in here so i'll watch a
lesson and then whatever command the lesson is on or whatever kind of task the
lesson is doing i'll hop into this book and i'll find it right and then i'll do
literally copy out the samples and then just run through so by then i'll have like
multiple examples because i'll do the examples from the course then i'll do the
examples from this book and then i'll keep going another book that i use is this
one called linux basics for hackers by no means do i want to become a hacker though
security is a very interesting topic and also something that i'd like to explore
but maybe next year because i'm just overwhelmed this year but this is great
because it teaches you a lot of different tasks but it gives you it teaches you
those tasks in like the context of a hacker so it's very hands-on like for example
you use things like or you learn things like using and abusing services and i know
there's uh like chapter on bash scripting and uh one that i really really enjoyed
that um i got a lot of benefit was this controlling file and directory permissions
permissions was something that i had to go over many many times like watch the
videos again read the linux command line book again and then read the security book
again until it finally got in here i was able to get hands-on enough to really
explore the commands that you're expected to know for the linux essentials
certification luckily the command line is something that's pretty easy to get
hands-on because it's not like hey you need a website to play around with or to
deploy in azure to play around with some service you really just need a command and
some kind of task whether that's editing or modifying permissions or you know bash
scripting or moving files around renaming all that kind of stuff right i just
summarized what i learned i'd spend an hour in the morning just kind of going
through the theory and watching the different material and then i would let the day
go like get my work done and towards the end of the day i spent another hour
getting hands-on and then writing the notes so by no means am i a linux expert but
i'm like five percent ahead of where i was before and that's progress right next
steps for me i'm studying for my next cert which is the linux foundation certified
sysadmin and here's when people are going to come in why aren't you studying for
the red hat cert look the red hat is great i simply don't need the recognition that
the red hat cert gives you and i like the fact that the linux foundation one is
distro agnostic plus they have a lot of overlap so if i study for one i probably
just have to fill in the gaps and i'll be able to take the other one alongside that
i'm doing a lot more hands-on things like i deployed a ghost block to an ubuntu
server on azure the next thing i want to do is deploy a next cloud server also
probably an azure and azure because i'm most comfortable and i have a lot of
credits there um yeah if you're not familiar with nexcloud it's an open source
alternative to something like g suite or office 3605 and like i mentioned at the
beginning this world of open source has so many things going on um i'm also in the
process of finding all the tools that i use in my workflow and and finding open
source alternatives for them because it looks like open source projects tend to
respect privacy a lot more right and i'm willing to support something like that
even if i have to pay for it because i think those things matter yeah so overall i
feel a lot more comfortable in the command line and i think that's a win especially
in any kind of technical role it's just crucial to understand what's going on the
command line yeah and that's it for this video i do want to give a shout out to a
couple of friends of mine elf richard and parveen they joined me on a stream last
thursday and we just talked about anything anything really um we all happen to work
in cloud related roles so it was kind of nice to just sit down and talk to friends
about you know working in cloud i want to do those more often i'm still trying to
figure out what's the best time i did put a poll in the community tab so go check
that out if you're interested in that and i'd love to have like a bunch of
different friends and and maybe even strangers as long as you're respectful to hop
on stream and then we can just chat yes and all right now this is the end of the
video i will see in the next video but if you made it this far i'm going to show
you how to use that command alrighty so let's display the file it's a text file and
you see we have gwen gps gwen gps gps going gps gps gps alrighty so how can we only
replace the second occurrence of gps with gwyneth on every single line well let's
use the stream editor command so it'll be said and then s for substitute and then
we'll first type in the word that we're looking for gps then we're typing in what
we're going to replace it with and then we're going to tell the command which
occurrence we want to replace so by putting 2 we're telling it hey we want to
replace the second occurrence now we tell it from what file just say textfile.txt
and i'm going to tell it to send the replace text to a sample file sample.txt there
we go so now if we take a look at the sample file you can see that we have very
similar output except the second occurrence of gps has been replaced with gwyneth
you see here gps gps it's now gweneth first second occurrence here it's now going
you notice that that first one hasn't been replaced right but say now we wanted to
replace the second occurrence in only the third line well we could preface the s
command the substitute command with a number to indicate
that so we can say something like said three s and then the rest is pretty similar
so gps gwyneth and then the second occurrence from the text file and let's create a
sample.2 oh i forgot the redirect there alrighty so now if i do cat sample two
we'll see here that the first line is the same the second line is the same and then
the third line the second occurrence of gps was replaced and that's a little crush
course on the set command

You might also like