Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Summary

Summary Files and commands in Linux

Rating
-
Sold
-
Pages
6
Uploaded on
31-05-2024
Written in
2023/2024

This guide describe the displaying the contents of files.

Institution
Course

Content preview

File Commands in Linux

Displaying the Content of Files
You use the cat (concatenate) command to display the contents of a specified file. The
cat command can vertically concatenate the contents of more than one file.
Example
[Steveelocalhost Steve]$ cat atal
A sample file
(Steveelocalhost Steve]$
When you type the above command, it is assumed that the file datal is in the current
directory. However, you can also specify the complete path to display a file in another
directory.
Youcan also use the cat command to display the contents of more than one file, as shown in
the following command:
Example
[SteveGloca l host steve) $ cat datal data2
A sample file
Another sample file
(Steve@localhost Steve]$

, The head and tail Commands
Vau use the head commandto display the specifiednumber of lincs from the
beginning of a
6le Youuse the tail command to display the specified number of lines from the end of a file.
Ifvou do not specity aparametcr, 10 lines are displayed by default. The syntax for both the
commands is:

Syntax
head [options] [file name]
tail [options] [file name]
Youuse the head or tailcommand to display a certain number of lines on the screen.
Erample
$ head -3 /etc/passwd
root:x:0:0:root:/root :/bin/bash
bin:x:l:l:bin:/bin:
daemon:x:2:2:daemon:/sbin:

This command displays the first three lines from the beginning of the file /etckpasswd.
Some of the options available with the head command are given below:

Table 3.4: Options of the head Command

Option Functlon

C,-bytes-SIZE Displays the first<size> bytes.
of the first 10lines.
1,ines-NUMBER Displays the first <number> of lines instead

4, verbose Displays headers with file names.


Example
$ l8 -1 | tail 2
Steve 38 Oct 19 22: 28 y
-W-W-r 1 Steve
y.bak
-IW-rW-r- 1 Steve Steve 48 Oct 12 05:09
ls -l command.
This command displays the last two files from the output
output of
of the

Connected book

Written for

Institution
Course

Document information

Summarized whole book?
No
Which chapters are summarized?
Managing files and directories
Uploaded on
May 31, 2024
Number of pages
6
Written in
2023/2024
Type
SUMMARY

Subjects

$18.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
mythreyevenkatesan

Get to know the seller

Seller avatar
mythreyevenkatesan vellalar matriculation higher secondary school
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
1 year
Number of followers
0
Documents
20
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions