File Oriented Commands in Linux
File Oriented Commands in Linux
COMMANDS
bhatvijetha 1
Cat
This cat (catenated –concatenate) command is used
to display the contents of the specified file.
General format :
Cat [-options] <filename1> [<filename2>…]
Where options can be,
S suppresses warning about non-existing files.
d lists the sub-directory entries only
b numbers non blank output lines
n numbers all output lines
bhatvijetha 2
Example
$cat a.c
This will display the contents of the file , a.c
$cat a.c b.c
This will display the contents of the files a.c and b.c one by
one.
bhatvijetha 3
Cp
This cp command is used to copy the content of on file into
another file .
bhatvijetha 4
rm
The rm (remove )command is used to remove a file from
the specified directory.
To remove a file you must have a write permission for the
directory that contains the file but you need not have
permission on the file itself.
General format is,
Rm [-options] <filename>
Where options can be,
r deletes all directories including the lower order directories.
I prompts before deleting
f removes write protected files also,without prompting.
bhatvijetha 5
Example
$ rm a.c
This command deletes the file a.c from the current
directory.
bhatvijetha 6
Mv
This command is used to rename the specified
files/directories.
For move command the user must have both write and
execute permissions on the source.
Example:
$mv a.c b.c
Then file a.c is renamed as b.c.
bhatvijetha 7
Wc
This command is used to display the number of lines words
and characters of information stored in a specified file.
General format is,
Wc [-options] <filename>
Where options can be,
l displays the number of lines in the file
W displays the number of words in the file
C displays the number of characters in the file
Examples:
$ wc a.c
It displays the number of lines, words and characters in the
file.
bhatvijetha 8
Cmp
This cmp command is used to compare two files.
bhatvijetha 9
File access permissions
There are 3 types of file in linux.
Ordinary file
Directory file
Special file(device file)
bhatvijetha 10
There are 3 types of modes for accessing thes files as follows,
Read mode
Write mode
Execute mode
The file permission is displayed in 10 characters.
bhatvijetha 11
Touch command
This command is used to create a new empty file.
The length of the file created is zero.
Head command
The head command is used to display few lines at the
beginning of one or more files.
This is used in verifying the contents of a file.
By default it displays the first 10 lines of a file.
bhatvijetha 12
Remaining commands Continued …in part3
presentation
bhatvijetha 13