From the course: Learning Linux Command Line
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
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
-
-
-
-
-
-
The Unix philosophy2m 29s
-
(Locked)
Use pipes to connect commands together2m 41s
-
(Locked)
View text files with cat, head, tail, and less4m 44s
-
(Locked)
Search for text in files and streams with grep4m 30s
-
(Locked)
Manipulate text with awk, sed, and sort6m 50s
-
(Locked)
Edit text with Vim4m 35s
-
(Locked)
Edit text with nano2m 49s
-
(Locked)
Working with tar and zip archives8m 17s
-
(Locked)
Challenge: Create and share a file28s
-
(Locked)
Solution: Create and share a file1m 48s
-
(Locked)
Output redirection5m 11s
-
(Locked)
Exploring environment variables and PATH3m 54s
-
(Locked)
Challenge: Extract information from a text file1m 8s
-
(Locked)
Solution: Extract information from a text file3m 28s
-
-
-