Operate File Contents

LinuxIntermediate
Practice Now

Introduction

In this challenge, you will learn to use some file operation command that allows you to perform actions such as viewing the contents of the file and operating or filtering the contents of the file.

Achievements

  • cat - print the contents of the file.
  • head - operator contents of the file.

In the step, you will try to get the file contents.

Tasks

  • Use cat command to get the /tmp/hello contents.
  • Display the line number of the file contents.

Requirements

  • Number the number of rows for all outputs, starting with 1

Example

1 I am Labby!
2 I am Labby!
3 I am Labby!
4 I am Labby!

cat is a command that gets the file contents. It is useful when you want to preview the file contents.

Now ask you to complete the /tmp/hello file retrieval operation.

Displays The Line Number

Number the number of rows for all outputs, starting with 1

Now please print the lines of data in the /tmp/hello file via the full path.

Operator File Contents

The head command can be used to view the specific contents of a file.

Get Row Data

Now please print the first line of data in the /tmp/hello file via the full path.

Get Byte Data

Unlike above, now you can get the first byte in the /tmp/hello and output it.

Summary

Congratulations! You have completed the file operations challenge.

In this challenge, you learned three basic operations commands ls, cat, and head. These commands are used frequently, so be sure to keep them in mind.

Keep exploring!

✨ Check Solution and Practice✨ Check Solution and Practice