From the course: Learning Linux Command Line

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Solution: Extract information from a text file

Solution: Extract information from a text file - Linux Tutorial

From the course: Learning Linux Command Line

Solution: Extract information from a text file

(upbeat music) - [Instructor] Let's take a look at how I solved this challenge. The file that we were provided was an archive, so the first step that I took was to write tar -xvf log.tar.gz. And this created a file called auth.log. As I'm sure you found out, that file's hundreds of lines long. So I wanted to get a sense of what I was looking for. Next, I wrote less auth.log, just to take a look at all the text. And scrolling around, I started seeing invalid user login attempts. For example, this line shows invalid user oracle, another shows invalid user db1inst1, and so on. Scrolling down, I can see user zznode, user ftpuser, and so on. Each of these lines has the string input userauth_request, so I know I can look for that. And on these lines, the username occurs at a specific position. I can count from the left, 1, separator, 2, 3, 4, 5, 6, 7, 8, 9. On each of these lines that say…

Contents