Editing
Solaris 10 Associate
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Modifying Directory Contents == === Copy Files & Directories === ==== Copy Files ==== Use cp command to copy the contents of a file to another file. Syntax: * cp -option source_file target_file_or_directory Common options: * -i (prevents accidental overwrite of file or directory, prompts user when an overwrite might occur) * -r (recursive, includes the contents of directory and all sub-directories when copying a directory) Examples: Copy file within a directory: <code>cp source_file target_file</code> Copy multiple files to a different directory (relative path example): <code>cp source_file1 source_file2 target_directory</code> ==== Copy Directories ==== Use cp -r command & option to copy the contents of a directory recursively to another directory Syntax: * cp -options source_directory target_directory Note: * If target_directory does not exist one will be created with source_directory name. * If target_directory exists a new sub-directory below target_directory will be created with source_directory name. Copying multiple directories Syntax: * cp -options source_directory1 source_directory2 target_directory === Moving Files & Directories === The mv command moves & can rename files & directories within the directory hierarchy Syntax: * mv -option source_file_or_directory target_file_or_directory Examples: Rename file1 in same directory to file2: <code>mv file1 file2</code> Move file1 to another directory: <code>mv file1 ../</code> Move & rename file1 to file2 in another directory: <code>mv file1 ../file2</code> Move & rename directory1 to directory2 in same directory: <code>mv directory1 directory2</code> === Creating Files & Directories === ==== Creating Files ==== You can use touch command to create an empty file or a text editor program Syntax: * touch filename ==== Creating Directories ==== Use mkdir command to create directories Syntax: * mkdir directory_name * mkdir -p directory_names (-p creates all the parent directories that do not exist) === Removing files & directories === Remove file using rm command. Syntax: * rm -option filename rm options: * -i (prompts before deleting each file) Remove empty directories. If directories are not empty an error message will result. Syntax: * rmdir directories Remove directories that are not empty Syntax: * rm -options directories rm options: * -i (prompts before deleting each file or directory) * -r (recursive, includes all contents of directory and sub-directories) === Using Symbolic links === A symbolic link is a pointer that contains the path name to another file or directory. Use ln -s command to create a symbolic link file. The file name for the symbolic link appears in the directory in which it is created. Syntax: * ln -s source_file target_file Where source_file variable refers to the file, either relative or absolute path, in which you create a symbolic link. The target_file variable refers to the name of symbolic link. If source file does not exist a symbolic link called target_file to a non-existing file is created. You remove symbolic link files the same way you would any other file using rm command.
Summary:
Please note that all contributions to GotOpinion may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
GotOpinion:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
Edit source
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information