Hot answers tagged

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


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


3

You can use something similar to this: #!/bin/bash counter(){ for file in "$1"/* do if [ -d "$file" ] then echo "$file" counter "$file" fi done } counter "$1" Run it as ./script.sh . to recursively print directories in under the current directory or give the path to some other directory to traverse.


3

You can achieve that with ACLs, check this answer for an introduction: http://unix.stackexchange.com/a/12847/130303 You'll probably need default ACLs to achieve what you want to do. Lets say you have a directory test (with files and dirs already in it) and you want user and group to be able to write and others only to read, you can set default ACLs (...


3

If you don't have write permission in the parent directory, you can't make any changes in the parent directory; this includes deleting the target directory, and creating a symlink. In any case, ln won't overwrite a directory, even with -f.


2

TBH this is probably more suited to one of the other .SE's, either Unix &Linux, Ask Different, or even SuperUser. Which is why I assume you've been downvoted. That said... The Short Answer The answer is rm -r ./--crm, or better yet, rmdir ./--crm. The Real Answer On OS X you're usually using Bash in the terminal, which is important to know: which ...


2

The easiest thing to do is to for a permanent result is to give the filesystem a label. The way you do this depends on what filesystem you formatted it as. First find the device it is on: $ findmnt /mnt/d1b2aa11-a3e4-434b-b71c-47a8ac23ac23 TARGET SOURCE FSTYPE OPTIONS ... /dev/sdc1 vfat ... For example, above it is on /dev/sdc1 (check this isn't ...


2

In a zip file, only file contents is encrypted. File metadata, including file names, is not encrypted. That's a limitation of the file format: each entry is compressed separately, and if encrypted, encrypted separately. You can use 7-zip instead. It supports metadata encryption (-mhe=on with the Linux command line implementation). 7z a -p -mhe=on Directory....


2

ls displays that information because the data is stored in the size field of the inode for the directory. This is filesystem dependent. A given filesystem could hold other information there. As an example, ZFS reports the number of directory entries in that field. If that's the level you're interested in, then reading the data is simple. ls and stat are ...


2

The trailing '/' on the source directory name is a subtlety of rsync. Pay attention to it. rsync A trailing slash on the source effectively means "copy the contents of this directory, not the directory itself". Without the trailing slash, it means "copy the directory". So rsync -a tmp/24/ host:/target will copy the contents of "/tmp/24/" into "host:/...


1

huh, so my problem can be solved like this: ssh host "mkdir -p /target" scp tmp/24/* host:/target


1

You can override the builtin compgen for simple directory completions (as for cd and ls). For example, put this function in your ~/.bashrc compgen(){ local IFS=$'\n' local x tmp x=$( builtin compgen "$@" ) && while read -r tmp; do [[ "$tmp" =~ ^/home/e && ! "$tmp" =~ ^/home/elsherbini$ ]] || echo "$tmp" ...


1

I'm using zsh which allows completion to be customized very thoroughly. This option prevents certain patterns from completion: autoload -Uz compinit; compinit # ignore some common patterns that we usually don't want as completions zstyle ':completion:*' ignored-patterns "/usr/share/iscan" "/usr/lib/iscan" \ "iscan" "/usr/lib/ispell" "ispell" "/usr/...


1

One way I'd suggest is to have an alias if we are just concerned about the home directory path, adding the below to your profile would help here, whatever unique alias you made should autocomplete with even a first character. alias myHome="cd /home/elsherbini" . .profile my\T pwd /home/elsherbini EDIT: The other way could be binding a key but even this ...


1

Yes, there is: it's called ls… The size reported by ls for a directory is the size of the directory contents. It isn't metadata of the directory, it's metadata of the files in the directory. Most of that is listed with ls -la. On some Unix variants, you can display the binary form of that data by calling cat (or od, etc.) on the directory. This is not the ...


1

You could create an archive using your favorite tool and then use bcrypt to perform encryption/decryption. A) To create an encrypted file: tar -czf Directory.tgz /path/to/directory bcrypt Directory.tgz This will give you a Blowfish-encrypted file Directory.tgz B) To reverse this process: bcrypt Directory.tgz.bfe tar -xf Directory.tgz


1

You can use GParted to rename partition. To install GParted use, $ sudo apt-get install gparted Launch GParted -> Unmount the drive -> Rename by setting new label. For more info visit this website.


1

This worked using bash on Ubuntu. It only matches duplicate directories irrespective of depth in the tree. The portion within the $() builds a list of pipe-separated directory names by counting duplicates in the last column of ls -l. This pipe-separated list is filtered using grep over the list of all directories. Also, not accounting for other files (didn't ...


1

You can use -type d in the find string: find /path/to/target -type d -mtime 1



Only top voted, non community-wiki answers of a minimum length are eligible