Skip to content
Advertisement

Tag: rm

delete all files except a pattern list file

I need to delete all the files in the current directory except a list of patterns that are described in a whitelist file (delete_whitelist.txt) like this: How can I perform this in one bash line? Answer Any bash script can fit on one line: Check the output and then, if it’s OK:

What does rm ** does in LINUX [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question

Delete all files except a few using bash command

I have a directory containing lot of files in different formats. I would like to know how I can delete all files with specific format (Lets say *.dat) except a few files in a same format (e.g. A.dat and B.dat). Please advise! Answer I’d write a little script (as a command-line one-liner it is slightly too big): As an alternative,

Linux/shell – Remove all (sub)subfolders from a directory except one

I’ve inherited a structure like the below, a result of years of spaghetti code… In reality, this folder is thousands of subfolders large. I only need to keep ./gallery/{number}/full/* (i.e. the full folder and all files within, from each numbered directory within gallery), with everything else no longer required and needs to be deleted. Is it possible to construct a

How to enable confirmation alert when using ‘rm’ command to delete files / folders? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question

Command Line to find and delete Similar files in Linux

I want to find and delete all the “similar files as shown below” recursively from the specified directory of my Linux Server by Using COMMAND LINE…. “file.php?p=10&file=load%2Fnew Animations 1%2FAwesome_flowers-(text1).gif&sort=0” “file.php?p=10&file=load%2Fnew Games 1%2FAwesome_flowers_-(text1).gif&sort=1” Note: All these files having different file sizes and The mathed text is in all files is “file.php?p***” Answer This should help you to delete files recursively.. find

Advertisement