“cat” command
the cat command can be used to display
contents of files ,write into files or to concatenate files.
Displaying a file using “cat”
command
$ cat filename
ex:
Writing into files using “cat”
command
$ cat > filename
#things to be
# written
#in the file
#
once you finish press enter to go to a
new line and then press ctrl +D to close file.
ex:
Appending in to a file using “cat”
command
similar to writing a file using cat
but use >>
$ cat >> filename
# new content
#to be appended
#to the file
ex:
Concatenating files using “cat”
command
several files can be concatenated to a
single file using cat command
$ cat file1 file2 file3 > newFile
(* this is useful to merge a file
that has been split into several parts by the “split” command )
ex:
“more” command
The “cat” command displays the
entire file at once. So it maybe a disadvantage when viewing a large
file using cat because we may only see the last part of the file.
Therefore viewing large files the “more” command is a better
option.
The “more” command displays a file
page by page.
$ more filename
:)
ReplyDelete