New answers tagged

3

You can use the debugfs utility, debugfs is a simple to use RAM-based file system specially designed for debugging purposes First, run debugfs /dev/sda2 in your terminal (replacing /dev/sda2 with your own partition). Once in debug mode, you can use the command lsdel to list inodes corresponding with deleted files. When files are removed in linux ...


0

This means your filesystem is damaged, Input/Output errors during filesystem access attempts generally mean hardware issues. Type dmesg and check for log. it might be because of connection to it is failing, it'll be noted there. is it mounting it via ntfs or ntfs-3g ? As I recall, the legacy ntfs driver had no stable write support and was largely abandoned ...


0

It's a bit longer but I alway like find when I want to get specific. This should retain the structure and ignore the img dir. find ./static -type d ! -name 'img' -exec rm -f {}/* \; A breakdown of what's going on find The command ./static specifying where to search type -d Singling out directories ! -name 'img' Ignoring img dir -exec rm -f {}/* \: ...


0

Try this (note the !) dir1=/source/dir/path/ while ! inotifywait -qqre modify "$dir1"; do rm -r /destination/dir/path find /source/dir/path/ -name .svn -exec rm -rf '{}' \; cp -ruv /source/dir/path/* /destination/dir/path/ done


2

Your command is treated * as a file, try rm -rf ./static/{css,js}/ Alternatively, Bash has extended globbing (first test, then remove the echo): $ shopt -s extglob $ cd static $ echo rm -rf !(img) Or Short Answer ls | grep -v "img" | xargs rm -rf As suggested by OP in comment, Follow this step to do your job. First dry run by printing the files to ...


0

It's theoretically possible that the simultaneous (concurrent/parallel) execution might be slower.  It's conceivable that the operating system might keep each directory clustered.  I.e., the contents of dir1 might have inode numbers that are close to each other, and use data blocks that are close to each other.  And the same might be true for dir2.  But the ...


1

Like alx741 said I don't think you're going to get any real benefit one way or the other unless they're on separate file systems. I did some testing with a 700MB file. Here are my tests that backup my thoughts. I don't have multiple local partitions to play with so I can't test that. Here it is as one command sequentially. time rm -f test.dat1 test.dat2 ...


3

It depends. If the files being removed are in the same file system and hardware device they will eventually be sequential anyways, because the operating system will wait the physical resource to do the actual operations in the hardware. Although each instance of rm will queue the operations so one is available when the other finishes, don't expect a big ...


1

Run this first to make sure it gets the desired dir's find ${DIR_LOG} -type d -mtime +90 -name "20[0-1][0-9][0-9][0-9][0-9][0-9]" then run this to actually delete them. find ${DIR_LOG} -type d -mtime +90 -name "20[0-1][0-9][0-9][0-9][0-9][0-9]" -exec rm -Rf {} \;


1

find . -name '*.bedgraph' -delete should work. Be careful not to delete anything inadvertently.


83

Removing the current directory does not affect the file system integrity or its logical organization. Preventing . removal is done to follow the POSIX standard which states in the rmdir(2) manual page: If the path argument refers to a path whose final component is either dot or dot-dot, rmdir() shall fail. One rationale can be found in the rm manual ...


-1

Make sure the directory is correct then sudo rm -rf * .*


11

* only includes visible files. If you want to delete both those and the hidden ones, use: rm -rf * .* The dotglob option With bash, we can change this behavior and unhide files. To illustrate, let's create two files, one hidden and one not: $ touch unhidden .hide1 $ ls * unhidden As you can see, only the unhidden one is shown by ls *. Now let's set ...


7

It's done like that for integrity since you are currently inside that directory and the . is only a self-reference. You need to either go in its parent or call rmdir with its path, which can be done with: rmdir `pwd` If you often need that, you can set an alias to it like: alias rmc='rmdir `pwd`' .. which could be called as rmc alone to remove ...


4

There's no link from a file to symlinks that point to it, so there's no direct way of considering example and finding link_example which links to it. So deleting symlinks pointing to a file along with the file involves finding all the symlinks first. You don't specify what system you're using, but if you have GNU find, you can delete a file and its links ...


2

Are there any secure UNIX tools to recover data, that was removed with rm, from a USB flash drive? Yes and, by the way, recovery of photos is one of the most common scenarios. The conditions you described are actually optimal because: you directly deleted the files the file system is not damaged you did not use the drive anymore These conditions lead ...


3

Best practice would be to not only unmount but additionally disconnect the backup. You presumably expect your backup to protect you in case (for example) someone accidentally downloads a cryptolocker. Or someone breaks in (compromises) your system. Or a weird system crash that corrupts filesystems. Or a lightning surge that fries all your electronic devices ...


3

rm --one-file-system should do the trick. --one-file-system when removing a hierarchy recursively, skip any directory that is on a file system different from that of the corresponding command line argument Source: http://man7.org/linux/man-pages/man1/rm.1.html


0

If there is a chance there is a file manager in that host you can launch it from the terminal and remove the file there. This will run nautilus in the current directory: nautilus . This will save you from unintentionally remove the wrong file, or worse.


0

You can use the "-i" (interactive) option of /bin/rm. Of course, you need to be very careful. In this particular case I would do this: cd && /bin/rm -i *Apps* It is possible that "Apps" will not match anything, and in that case (being VERY careful): cd && /bin/rm -i * This is typically the best way to delete files that have hidden ...


1

In the UNIX shell, backslashes need to be escaped or single quoted. You can remove those files with one of the following: rm '\home\sluddani\installApps' OR rm \\home\\sluddani\\installApps


1

mv regression regression.old rm -rf regression.old & mkdir regression run_regression Rename the old regression directory, delete it in the background, make a new regression directory, and then run your program. if run_regression creates the directory itself if it doesn't exist then the third step isn't necessary. A safer version, in case regression....


3

Your parenthesis attempt lacked spaces around them so find saw an option called (-name and didn't know what to do with it. Instead, add spaces around the parens like: find . \( -name "*.xml" -o -name "*.ipm" \) -type f -exec rm -iv {} \; Also, if you have GNU find you can use -delete instead of the -exec rm -iv {} \; As Wildcard noted, since we're doing ...


2

rm -rf regression/* runs in parallel with ( sleep 10 ; run_regression ). This means that you have no guarantee as to the order of things. rm -rf regression/* first collects the list of files in the regression directory, then invokes rm to delete them. This doesn't happen by magic, it's the shell doing the work as part of evaluating the command rm -rf ...


2

Using parenthesis works, but you need to escape them so the shell does not interpret them as subshell invocations. You can use backslash, \( and \) or quotes. If none of your files have names that contain newlines or other control characters, which should be the case unless someone tries to be nasty, then you can use the pipe to xargs approach, which is the ...


5

Although your command probably works, here is a test case: $ ls $ echo * $(sleep 1)&touch file1 [1] 12798 $ file1 [1]+ Done echo * $(sleep 1) Note that file1 was not typed in, it was the output of the echo command. Edit: Another test run: $ ls $ touch file1 $ for i in {1..5000}; do rm * & touch file$i; wait;done|grep file ...


4

This is not safe. You have not specified what the problem is that you are trying to solve. If your problem is that you want your directory to always be there but be cleaned up from time to time, I would suggest explicitly removing files older than a check file (the sleep 1 is me being paranoid): touch regression.delete \ && find regression \! -...


0

It's only safe if you use new filenames. The shell knows about filenames, not their inode, etc., and does the globbing (expansion of wildcards) before running a command. According to POSIX: 2.6.6 Pathname Expansion After field splitting, if set -f is not in effect, each field in the resulting command line shall be expanded using the algorithm ...



Top 50 recent answers are included