-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinux-clRF
More file actions
38 lines (27 loc) · 1.37 KB
/
linux-clRF
File metadata and controls
38 lines (27 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
rm filename1 filename2 filename3
Copy
You can also use a wildcard (*) and regular expansions to match multiple files. For example, to remove all .pdf files in the current directory, use the following command:
rm *.pdf
Copy
When using regular expansions, first list the files with the ls command so that you can see what files will be deleted before running the rm command.
Use the rm with the -i option to confirm each file before deleting it:
rm -i filename(s)
Copy
To remove files without prompting, even if the files are write-protected, pass the -f (force) option to the rm command:
rm -f filename(s)
Copy
You can also combine rm options. For example, to remove all .txt files in the current directory without a prompt in verbose mode, use the following command:
rm -fv *.txt
Copy
How to Remove Directories (Folders)
In Linux, you can remove/delete directories with the rmdir and rm.
rmdir is a command-line utility for deleting empty directories, while with rm you can remove directories and their contents recursively.
To remove an empty directory, use either rmdir or rm -d followed by the directory name:
rm -d dirname
Copy
rmdir dirname
Copy
To remove non-empty directories and all the files within them, use the rm command with the-r (recursive) option:
rm -r dirname
Copy
If a directory or a file within the directory is write-protected, you will be prompted to confirm the deletion.