New answers tagged

1

It seems that your file was created using superuser sudo (root/admin) attributes so, in order to modify o delete this file you would need to authenticate as a sudo, to do this simply type: sudo rm -rf path/to/file here rm -rf stands as remove recursively so that if path/to/file is a folder all its content will be removed. Your machine will ask you for ...


0

You could try to delete the folder with sudo. sudo rm -rf foldername


7

If you only want to delete a file in /home/charlesingalls (and not a file in a subdirectory) then it's easy: just check that the argument doesn't contain a /. case "$1" in */*) echo 1>&2 "Refusing to remove a file in another directory"; exit 2;; *) rm -f /home/charlesingalls/"$1";; esac This runs rm even if the argument is . or .. or empty, but ...


2

If you want to forbid paths completely, the simplest way is to test if the variable contains a slash (/). In bash: if [[ "$1" = */* ]] ; then... This will block all paths, though, including foo/bar. You could test for .. instead, but that would leave the possibility of symlinks pointing to directories outside the target path. If you only want to allow ...


10

This answer assumes that $1 is allowed to include subdirectories. If you are interested in the simpler case where $1 should be a simple directory name, then see one of the other answers. Wildcards are not expanded when in double-quotes. Since $1 is in double-quotes, wildcards are not a problem. Both ../ and symlinks can obscure the real location of a ...


1

A much better way to do this is: find . -name ".svn" -type d -prune -exec rm -rf '{}' '+' In case you have ".svn" inside another ".svn".


1

The following script may do what you want (I have it set to echo what it would do, rather than actually do it, so you can see) #!/bin/bash # This variable will always be in lower case. That means that if you do # l=Hello the result will be $l==hello. typeset -l l for f in * do l=$f # Forces to lowercase due to typeset if [ "$l" != "$f" -a -e "$l" ] ...


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 {}/* \: ...


1

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


3

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 ...



Top 50 recent answers are included