File Commands
1. cat command
Lists the contents of the specified file. If we do not specify the name of the file , it takes input form the standard input.
Options of cat commands are as follows:
cat
: Displays the contents of the specified file.
cat –s
:Suppresses warning about non-existent files
cat >
:Creates a new file with specified file name. Takes input from standard input file. We can type in our text and terminate with ctrl+d to take us back to prompt.
cat >>
:Appends data to the specified file
Conventions of filename
• Filename can be of maximum 255 characters.
• Special chars can be protected with quotes.
• Filename are case sensitive.
• Filenames beginning with dot is hidden file.
2. head
Displays the first ten lines (default) the text file.
head –n N
This command creates a copy of source file and gives the file name specified in destination file.
cp
cp –r:
4. touch
Creates zero length (blank) files namely file1, file2, ….. fileN.
5. mv command
This command is used to rename and move ordinary and directory files.
For this we need both execute and write permissions.
.mv
We can also use this command to rename files as follows:
.mv
This command removes the specified file.
The options available with this command are
:rm -i= Prompts the user if he/she wants to delete the mentioned file.
:rm -r= Recursively deletes the entire contents of the directory as well as the directory itself.
:rm –ir= Interact with the rm command and deletes a directory.
Wild Card Characters
Group of files can be accessed using the wild card patterns.Various wild card patterns are as follows:
*:Match zero or more characters
?:Match any single character
[abx]: Matches any single character from given character
[a-e]: Matches by single character from given range
[^a-e]: Matches any single character except given range of character (^ stands for ‘not’)
Saturday, July 4, 2009
Linux File Commands
Posted by Reema at 11:08 PM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment