Tag Info

Hot answers tagged

12

Many entities in *nix style (and other) operating systems are considered files, or have a defining file-like aspect, even though they are not necessarily a sequence of bytes stored in a filesystem. Exactly how directories are implemented depends on the kind of filesystem, but generally what they contain, considered as a list, is a sequence of stored bytes, ...


11

In the Unix Way of Doing Things: everything is a file. A directory is one (of many) type of special file. It doesn't contain data. Instead, it contains pointers to all of the files that are contained within the directory. Other types of special files: links sockets devices But because they are considered "files", you can ls them and rename them and ...


9

My answer is mere reminiscence, but in 199x vintage Unixes, of which there were many, directories were files, just marked "directory" somewhere in the on-disk inode. You could open a directory with something like open(".", O_RDONLY) and get back a usable file descriptor. You could parse the contents if you scrounged through /usr/include and found the ...


9

You need write permission in the parent direct ory to delete anything from it. In your case this is /home, and as only root has write permissions here only root can delete items from it.


6

* is expanded by the shell before tar gets executed. So, making tar change the directory invalidates the arguments that * expanded into. You can simply tell tar to compress the directory instead: tar -czf /backupmnt/abc.tar.gz -C /backupmnt/statusService/ . The . represents the current directory, which will change when tar changes directories. This will ...


6

You could use system(command) Execute the operating-system command command and then return to the awk program. Return command’s exit status. e.g.: awk -F: '{if(system("[ ! -d " $6 " ]") == 0) {print $1 " " $3 " " $7}}' /etc/passwd


6

I don't think that [ -d ] is an awk thing, that's a shell thing. I would just do it this way instead: awk -F: '{ print $1,$3,$7}' /etc/passwd | while read name uid shell; do [ -d "/home/$name" ] || echo "$name $uid $shell"; done Of course, as very correctly pointed out by @Janis, you can do the whole thing in the shell: while IFS=: ...


4

It is almost awk... perl -F: -ane 'if(!-d $F[5]){ print "$F[0] $F[2] $F[6]" }' /etc/passwd


3

A directory is special in that it has the 'd' in its mode, telling the filesystem that it should interpret its contents as a list of other files contained within the directory, rather than a regular file that is just a sequence of bytes to be read by the application. That is all.


3

I just looked at the maldet source code, and can see that the bug lies here, where paths are not properly quoted. Because the path is not properly quoted, the logic being performed fails (as it only looks at part of the path). Frankly, I can't even tell what the end goal of that part of the function is because the code is so full of redundancy, bugs, and ...


2

The command cp -f * /var/www/ copies files matching * in the caller's current directory, i.e. your current directory. It is irrelevant where the script is located.


2

This can be easily done by using NFS. You'll have to install a NSF server on your host (very easy) and then mount the directory on the guest. https://wiki.archlinux.org/index.php/NFS


2

When sticky bit is set, only the file's owner, the directory's owner, or root can rename or delete the file. The sudo command is there to enable a user to impersonate another user, including root. When user2 issues a command through sudo to become root, he's getting root's permissions, and root always has all permissions on the system.


2

A crude way to do it: for f in /path/to/PDFs/*.pdf; do base=$( basename "$f" .pdf ) if [ ! -f /path/to/PNGs/"$base".png ]; then mv "$f" /path/to/garbage/ fi done


2

Why do not use explicit directory change? cd /backupmnt/statusService && tar -czf /backupmnt/abc.tar.gz * Or you can use relative paths: cd / tar -czf /backupmnt/abc.tar.gz backupmnt/statusService1/* backupmnt/statusService2/* backupmnt/statusService3/* Which can be even better solution as you will keep files separated in folders and avoid ...


1

The GVFS documentation has a file about Controlling What is Shown in the User Interface. In short, you have two ways to do this: If it's in /etc/fstab, add x-gvfs-hide as one of the options (or, for older versions of udisks2, comment=gvfs-hide). Configure udev to set the $ENV{UDISKS_IGNORE}="1" for the relevant device. For example, here is how I hide ...


1

Directories are files because linux systems employ universal i/o model. In the model everything in the system is a file and it can be accessed with same system calls and various commands. They are of special type because their i-nodes have the mark for the file type and they have a special structure of being a table of filenames and links to other i-nodes. ...


1

The ext3 file system also uses a hash (discussion in debian-user). However, IMHO, this can have a bad consequence, at least for a traditional hard disk: this destroys some possible regularity / locality on disk. For instance, when files have been created one after the other in the directory, reading these files in the directory order can be very slow (see ...


1

mount ftp resource locally with: curlftpfs [user@]host:[dir] mountpoint [options] and do whatever you like like a local filesystem


1

You could use rsync instead of cp: rsync -R "${CURRENTDIRECTORY}"/"${NEWESTFILE}" "${DEST}" To limit the output path to be relative to MYDIR (for example test1/zip12.zip) you will have to enter the directory before find loop: cd $MYDIR and later find .. If you keep old files in backup directory you could even replace the whole script using rsync ...


1

If you are really using gawk (though you may be using nawk, or mawk, in which case this won't apply), you can do this natively using one of the loadable extensions available since v4.0. I'm using gawk-4.1.x (v4.0 had a variation on the syntax for loading extensions). Loading the filefuncs extension adds (amongst others) a stat() function: @load "filefuncs" ...



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