namestring might be at the beginning, center or end of the file name. We will enclose the problematic filename or folder name in quotation marks. From Linux shell, Let's say I'm in directory /dir and I want to find, recursively in all subfolders, all the files which contain in the name the string namestring and, inside, the string contentstring. So, how do we get rid of those directories with unusual names? The solution is straightforward. As an example:Īssume we have a folder called " Our Sales Data" and " baddir#" or " dir2 #" in it. Your folders and files may contain while spaces, semicolons, backslashes, and other characters in Linux. Rm -r -f -v /home/vivek/oldpartpics Delete Folders With Unique Name Characters In other words, the rm command on Linux will explain what happens to our files and folders. To see verbose outputs, we can use the -v option. To remove a folder whose name begins with a “ -,” such as “ -dsaatia,” use one of the following commands: Unless the -f (force) option is specified on the command line, the user is prompted to remove any write-protected files in the directories:Īlternatively, you can use the command that follows: In this example, we will delete the data folder in the current home directory recursively:īefore removing the data directory, the specified /home/vivek/data/ directory will be emptied of all subdirectories, including their subdirectories and files. Examples Of How To Delete A Folder Recursively In other words, "files" include photos, documents, directories/folders, SSD/hard drives, NIC, USB devices, keyboards, printers, and network communications. In Linux and Unix-like systems, everything is considered a file. Put quotes around your problematic filename/folder. Remove a directory or file whose name begins with a '-'. Recursively remove directories and their contents Never prompt for nonexistent files or arguments.
0 Comments
Leave a Reply. |