Tag Info

New answers tagged

0

I don't have access to OSX so this is a wild guess... but you can try other techniques to delete files, rather than relying on the shell's globbing to match. Try: find . -not -type d -print -delete or even find . -not -type d -print | perl -nle 'print; unlink'


2

I couldn't keep this simpler; this works but it assumes there are no files whose filename contains newlines in the target directory; first test the command using this: find . -type f \( -name "*.cut" -o -name "*.cut.bak" \) -exec bash -c '[ -f "$(<<< "{}" sed "s/\(.*\/[^.]*\).*/\1/").rec" -o -f "$(<<< "{}" sed "s/\(.*\/[^.]*\).*/\1/").mpg" ...


0

If the command is to be run on some small embedded device with very limited commands and shells (e.g. missing find, minimal shell à la sash), a possible approach would be to write some tiny C (or perhaps C++) program doing that, and compile that program to an executable (it would be nice to make that program a free software). You'll use nftw to recursively ...


1

If you just want to get rid of many files as soon as possible ls -f1 /path/to/folder/with/many/files/ | xargs rm might work okay, but better don't run it on production systems unless you desire service impact. This script works nicely for many files and should not affect the ioload of the system. #!/bin/bash FOLDER="/path/to/folder/with/many/files" ...


2

With zsh: setopt extendedglob # if not already in ~/.zshrc rm Task.<10->.store.log To avoid the arguments list too long: autoload zargs # best in ~/.zshrc zargs Task.<10->.store.log -- rm


5

A POSIX one, can handle file which contain newline in filename: find . -name 'Task.??*.store.log' -exec rm -f {} +


3

find . -name 'Task.??*.store.log' | xargs rm -f


2

You might use lftp instead of the regular ftp client. With lftp you can use mget -E /path/to/files which will delete the source files after succesful transfer. See http://lftp.yar.ru/lftp-man.html for the manual.


2

When you rm a file, the file isn't immediately deleted. rm internally invokes the unlink() system call to complete its file-removing job, and to quote the man page for unlink() (see man 2 unlink to read it in its entirety): unlink() deletes a name from the filesystem. If that name was the last link to a file and no processes have the file open ...


5

Despite its name, rm doesn't remove file. It actually unlinks -- removes directory entry referencing file. If there is still hard links for that file, data is kept intact. When program is executed, Kernel keeps a kind of hard links inside (they all are treated as same inode object), so data will be kept until last process closes unlinked file. Note how ...


1

Almost all programs nowadays have their programs run from memory (RAM) so they don't need to access the disc once loaded. Therefore their image on disc can be deleted without a problem.


3

The maximum length of the command line is set by the system and is sometimes 128KiB. If you need to remove many, many files, you need to call rm more than once, using xargs: find /var/log -type f -print0 | xargs -0 rm -- (Careful, this will find and delete all files in the subdirectories of /var/log etc. - if you do not want that use find /var/log/ -type ...


2

According to trash-put manpage, trash-put puts the files on the trash, which is defined by the FreeDesktop.org Trash Specification. In chapter Trash directories, Trashing follows such fallback process: Home trash, located in $XDG_DATA_HOME/Trash. In your case, it may be /root/Trash for root. It's also possible that sudo passed $XDG_DATA_HOME through, so ...


6

Those files you removed may actually still be opened by another process. In that case the file space will become available when that process closes it's handle to the file. You can lookup these files with lsof: lsof |grep "var/log"|grep deleted


1

By default bash doesn't glob dot-files, so to remove everything but hidden files in bash, using rm: rm * Sample output: ~/tmp$ ls -la total 8 drwxrwxr-x 2 user user 4096 giu 11 20:00 . drwxr-xr-x 21 user user 4096 giu 11 08:26 .. -rw-rw-r-- 1 user user 0 giu 11 20:00 .1 -rw-rw-r-- 1 user user 0 giu 11 20:00 2 -rw-rw-r-- 1 user user 0 giu 11 ...


1

Try this: shopt -u dotglob # disable globbing for dot files ls * If everything looks okay, replace ls by rm.


3

Because rm -i expects user's input from stdin, too. Try this: echo "$MOUNTPOINTLIST" | while read onelineforrm; do rm -i "${onelineforrm}testfileforwrite" < /dev/tty; done


0

From man xargs xargs reads items from the standard input, delimited by blanks (which can be protected with double or single quotes or a backslash) or newlines, and executes the command (default is /bin/echo) one or more times with any initial-arguments followed by items read from standard input. Blank lines on the standard input are ignored. ...


1

You can use: find . -name '* *' -delete


6

I would avoid parsing ls output Why not : find . -regex '.* .*' -delete No problem with rm :-)


5

Look at this Suppose name "strange file" Solution one rm strange\ file solution two rm "strange file" solution three ls -i "strange file" you see the inode then find . -inum "numberoofinode" -exec rm {} \; In case of very strange file names like !-filename or --filename use rm ./'!-filename'


24

You can just use standard globbing on the rm command: rm -- *\ * This will delete any file whose name contains a space; the space is escaped so the shell doesn't interpret it as a separator. Adding -- will avoid problems with filenames starting with dashes (they won't be interpreted as arguments by rm). If you want to confirm each file before it's ...


4

This is simple, these are the two most common ways: rm ./-yourfile or rm -- -yourfile


0

I tried this as a comment but it came out all on one line [Harry@localhost]~% touch ">" [Harry@localhost]~% cat > ">" line 1 line 2 [Harry@localhost]~% cat ">" line 1 line 2 [Harry@localhost]~% ls -l ">" -rw-r--r-- 1 Harry Harry 14 Jun 5 12:04 > [Harry@localhost]~% rm ">" [Harry@localhost]~% ls -l ">" ls: cannot access >: No such ...



Top 50 recent answers are included