Author |
Topic: Create / Delete File on Unix / Linux |
|
Unix member offline |
|
posts: |
7 |
joined: |
10/06/2011 |
from: |
Cupertino, CA |
|
|
|
|
|
Create / Delete File on Unix / Linux |
The cat command
To create a text file called foo.txt, enter:
$ cat > foo.txt
Hello world!
press CTRL+D to save file To display file contents, type
$ cat foot.txt
The vi command
$ vi foo.txt
Hello world!
press Esc+:+x+Enter to save file Note: Usually, on most filesystems, creating a file requires write permission on the parent directory (and execute permission, in order to enter the directory in the first place)
|
|
|
|
|
|
|
Unix member offline |
|
posts: |
7 |
joined: |
10/06/2011 |
from: |
Cupertino, CA |
|
|
|
|
|
The rm command |
rm (short for remove) is a Unix / Linux command which is used to delete files from a filesystem.
The syntax is as follows:
rm -f -r {file-name}
where:
-f: forcibly remove file
-r: remove the contents of directories recursively
To remove a file called foo.txt, enter:
$ rm foo.txt Note: Usually, on most filesystems, deleting a file requires write permission on the parent directory (and execute permission, in order to enter the directory in the first place)
|
|
|
|
|
|
|
|