Tag Info

New answers tagged

0

I've faced the same issue and I'm not allowed to run anything other than sudo su - devuser on dev server, so this is what I came up with: In devuser's .profile switch back to previous user home if found: prev_user_home=$(~/bin/home.sh) if [ -n $prev_user_home ] ; then cd $prev_user_home fi A script to determine a previous user. The script is ...


2

The modification time of a directory, like any other file (note how directories are called directories (a list of name/number mappings like a phone directory) and not folders) is updated whenever the content is modified. That is when a file is added (linked), removed (unlinked), or renamed in it. Beware that files can be linked to several directories. The ...


3

I would use find <PARENT_DIR> -type f -mtime 1 With 1 the time of last modification in days (you can prefix it with - or + to indicate "less than X days" or "more than X days") : so, if you want the the file modified in the last 3 days, you'll do -mtime -3


1

Not everything about the file, most of the metadata about the file is stored within the file inode, not the directory entry. The directory entry is just a struct of inode and filename - just enough information to translate from a filename to an inode and get to the actual file. You can safely imagine a directory as a dictionary: filename1 :> inode1 ...


1

There's no system-wide rule; but, the behavior you see in rsync is documented near the beginning of the rsync man page: rsync -avz foo:src/bar /data/tmp This would recursively transfer all files from the directory src/bar on the machine foo into the /data/tmp/bar directory on the local machine. The files are transferred in "archive" mode, ...


-1

Delete the folder "test" and all the files inside: rm -r test Delete all the files inside but keep the folder "test": rm -r test/*


0

With install, you can create a directory with a specific owner, group, and mode: install -d -o <user> -g <group> -m <mode> <path>


2

r allows listing — just the names. w deleting and adding. t prevents deleting — if you don't own it. x allows navigation — stating a file or directory: reading meta data, reading meta-data is needed to be able to access, add or delete a file within the directory. If you can not navigate, then you can not delete, add, or anything else.


4

If you are in the company directory then try this: cp file1 sales cp file2 sales OR cp file1 sales; cp file2 sales Or cp file1 file2 file3 sales The last is the easiest and can accomplish copying all files it a single subdirectory in one line. If you want to complete the task and copy each file to each subdirectory in one line, merge the second and ...


1

Your command can fail if dir1/dir2 exists but is not a directory. If you want to test whether dir1/dir2 exists at all, use -e [ -e dir1/dir2 ] || mkdir dir1/dir2 If you really need dir1/dir2 to be a directory, and an ordinary file with that name is an error and should be replaced, you can test for that case. [ -e dir1/dir2 ] && [ ! -d dir1/dir2 ] ...


4

When a directory has "x' (or searchable) permission, it is possible that specific files under a directory having for example 111 (--x--x--x) permission can be accessed if their name is known AND the permission of the destination file allows it. Directories with 'r' permission allow programs such as ls to basically open the directory as a file and read it ...


1

the permission to move/rename a dir, comes from the permission of the ".." dir (containing dir), not from the dir itself. Simple testcase $ mkdir testdir/subdir -p $ chmod -w testdir $ mv testdir/subdir testdir/othersub mv: das Verschieben von »testdir/subdir“ nach »testdir/othersub“ ist nicht möglich: Keine Berechtigung ==> no permission


0

You can let the globs resolve themselves. As far as I'm aware, this strategy should be very shell portable for every case except one in which you have read permissions for dir/ but only search permissions for dir/../. This is because read and search permissions are required to resolve a glob, but only search permissions to show up a match. set di[r]/* ...


2

Here's a POSIX-compliant way of testing whether dir is empty using only built-in shell constructs. The set command sets the positional arguments to dot files (including the always-existing . and ..) followed by non-dot files. If the directory is empty then the .* glob only matches . and .., and the * glob matches nothing so remains unexpanded. set dir/.* ...


0

I know of no direct way, and it also depends on whether you want also dot-files to be considered. This (or a variant thereof) may do what you want... set directory/* [[ -f $1 ]] || print empty


0

In any shell [ "$(find path_to_dir -mindepth 1)" ] || echo EMPTY


1

Edit: Because yaan is a directory ,you have to give the execute permission like that: sudo chmod 744 yaan Explanation: 7 => give the read, write, and execute to the Owner. 4 => give the read to the Group. 4 => give the read to the Others. From the chmod manual page execute/search only if the file is a directory or already has ...


0

Change permission on this way: sudo chmod 644 yaan w/o trailig slash. If you want to change it recursively use sudo chmod -R +r yaan just add read permission to world


2

You must remove the read permission on the directory for the other users e.g. by chmod 700 dirname You cannot allow access to a directory and hide just some of the files it contains.


3

du takes a -b option See the man page and the info page for more help: -b, --bytes equivalent to '--apparent-size --block-size=1'


5

This wildcard exists in ksh93, bash ≥4.3 (≥ 4.0 if there are no symbolic link to directories in your tree) and zsh. It's spelled **. In ksh93, it needs to be activated first with set -o globstar. In bash, it needs to be activated first with shopt -o globstar. ls -l src/**/foobar/**/*.java This won't do to make the copy, though. The target of cp is a ...


0

This made more sense to me mkdir -p /create/folder && tar -zxf haroopad-v0.13.0_x64.tar.gz -C /create/testfolder mkdir makes the folder although i dont quite understand the -p switch. && lets you execute a second command. i used typical tar -switches but at the end -C is used to change directories and extract to that location needed. ...



Top 50 recent answers are included