cat
Syntax :- cat [file....] - Concatenate and display the contents of files(s)
Examples:
# cat test.sh
Concatenate and display the contents of file "test.sh"
-------------------------------------------------------------------------------------------------------------------------
more
Syntax:
- more [filename].... - Display one screen at a time
Examples:
# more test.sh
|
|
|
Display the contents of file "test.sh"
------------------------------------------------------------------------------------------------------------------------
cp
Syntax :
- cp [-i] file1 new_file - Copy a file
- cp [-i] file [file...] dest_dir - Change file group
- cp -r [-i] dir [dir...] dest_dir - Copy directories
Examples:
% ls
ll.sh newfile smit.log
% cp ll.sh ll.sh.new
% ls
ll.sh ll.sh.new newfile smit.log
Description :
- -i : Prompts it with the name of a file to be overwritten. This occurs if the TargetDirectory or TargetFile parameter contains a file with the same name as a file specified in the SourceFile or SourceDirectory parameter. If we enter y or the locale's equivalent of y, the cp command continues. Any other answer prevents the cp command from overwriting the file.
----------------------------------------------------------------------------------------------------------------------
mv
Syntax :
- mv [-i] file new_file - Rename a file
- mv [-i] file [file....] dest_dir - Move files to a directory
- mv [-i] dir [dir...] dest_dir - Rename or move directories
Examples:
- #mv file1 new-file
Move file1 to a new or existing file (new-file)
- #mv file1 dest-directory
Move file1 to an existing directory (dest-directory)
- # mv old-filename new-filename
Rename a file in the current directory
Description :
- -i : Prompts it before moving a file or directory to and existing path name by displaying the name of the file followed by a question mark. If we answer with a line starting with y or the locale's equivalent of a y, the move continues. Any other reply prevents the move from occurring.
----------------------------------------------------------------------------------------------------------------------
rm
Syntax:
- rm [-if] filename [filename...] - Remove files
- rm -r [if] dirname [filename...] - Remove directories
Examples :
# rm test.sh
Remove the file "test.sh"
# rm -r hello
Remove the directory "hello"
Notice: This command is a dangerous operation that cannot be recovered, option -i is strongly suggested.
- -f : Force each file or directory to be removed without prompting for confirmation, regardless of the permissions of the entry.
- -i : Write a prompt to standard error requesting confirmation before removing each entry. This option ignores any previous occurrence of the -f option.
- It is strongly suggested to use the option " -i" when a user uses the command "rm" to delete a directory without mistake.
------------------------------------------------------------------------------------------------------------------------
ln
Syntax :
- ln source_file new_file - Link to a file
- ln source_file [source_file...] dest_dir - Link files to a directory
- ln [-s] source_dir linkfile - Create a symbolic link
Examples:
Description :
- -s : Create a symbolic link
- If the -s option is used with two arguments, target may be an existing directory or a non-existing file.If target already exists and is not a directory, an error is returned. source_file may be any path name and need not exist. If it exists, it may be a file or directory and may reside on a different file system from target. If target is an existing directory, a file is created in directory target whose name is source_file or the last component of source_file. This file is a symbolic link that references source_file. If target does not exist, a file with name target is created and it is a symbolic link that references source_file.
- If the -s option is used with more than two arguments, target must be an existing directory or an error will be returned. For each source_file, a link is created in target whose name is the last component of source_file, each new source_file is a symbolic link to the original source_file. The files and target may reside on different file systems.
Hard links Vs soft links
- Hard links : A hard link is a pointer to the file's i-node. For example, suppose that we have a file : a-file.txt that contains the string : "The file a-file.txt" :
0 comments:
Post a Comment
If there is any comments,Please leave a comment at here.