Tag Info

New answers tagged

0

If I undersood the question correctly you need files in myfiles which do not have symlinks in images: #!/bin/bash for f in myfiles/*; do list="$(find -L images/ -xtype l -samefile $f)" if [[ "$list" == "" ]]; then echo "$f does not have symlink." fi done


0

The PHP documentation sucks is very bad: vague, ambiguous, and misleading.  fileinode() is tersely defined as “gets file inode” or “returns the inode”.  But if you dig a little deeper, the documentation seems to start saying that this function returns the inode number.  An inode is more than an inode number.  The difference between “returning the inode of a ...


2

With zsh: print -rl ${(0)^"$(locate -0 ...)"}(N.) (0) is a parameter expansion flag that splits on NUL characters (as we use locate -0), short for (ps:\0:). With ^, instead of adding (N.) at the end of the array, we add it to each element. (N.) is a glob qualifier, . to match only regular files, N to remove the element if it doesn't match (doesn't exist ...


0

xargs will repeat command for each line if you specify -L 1 or -i parameter. See here $ locate --regex --basename "xfce4-keyboard-overlay$" | xargs -i bash -c '(test -d "{}" && echo "{}")' Admittedly, it is kicking of a new shell for each file, but it does have the benefit of being nice and compact. EDIT: I wasn't quite happy with that answer ...


1

You can't use inode to check if a file has been changed. It may or may not change when a file is renamed, or moved. It will typically stay the same unless moved onto another disk ...


-1

An inode used to be the on-disk structure that contained access permissions, ownership, size in bytes, and the disk block numbers of the disk blocks that contained a file's data. So, some metadata, and some data. The file's name was just an entry in a specially-marked file, called a "directory". The name was associated with the "inode number". ...


2

A file rename that doesn't cross file system boundaries is just a metadata change, so it should preserve the inode number. Generally speaking, opening a file and modifying its contents should not change its inode number, which only makes sense within a single file system anyway (but it will change the access times, for example). Note that some tools such as ...


0

My two cents: while IFS= read i; \ do \ if [ -f "$i" ]; \ then \ echo "$i"; \ fi; \ done < <(locate --regex --basename "xfce4-keyboard-overlay$") This is more or less the way G-Man did it combined with process substitution.


2

This is about as inelegant as the other answers, but maybe less inefficient: locate --regex --basename "xfce4-keyboard-overlay$" | while IFS= read -r f; do [ -f "$f" ] && printf "%s\n" "$f"; done (broken into two lines for readability).  The above will handle names containing spaces.  The IFS= seems to be necessary to handle names with ...


-1

What if you combine locate with file and grep?... $ for f in `locate --regex --basename "xfce4-keyboard-overlay$"`; do file $f; done | grep -vi directory


0

locate --null --regex --basename "xfce4-keyboard-overlay$" | xargs -r0 sh -c 'find "$@" -prune -type d' sh


0

The right thing so use is process substitution. wkhtmltopdf --title "$SUBJECT" -q <(command_with_output_stream) $OUTPUTFILE


0

guessing from comment, you seems to be able to do it with a temporary file, why not make a named pipe ? mknod magritte p inside you php code, just write to magritte. wkhtmltopdf should be run with /usr/local/bin/wkhtmltopdf --title "$SUBJECT" -q magritte $OUTPUTFILE you might specify the location more accurately. Still guessing, wkhtmltopdf is run ...


0

to make a program that opens a file by name read from the pipeline give it the special device name /dev/stdin ... for example: /usr/local/bin/program-to-output-the-html | /usr/local/bin/wkhtmltopdf --title "$SUBJECT" -q /dev/stdin $OUTPUTFILE or do this before the command you showed: SOURCEFILE=/dev/stdin then the program will open("/dev/stdin",...) ...


1

You should be able to do this using /dev/stdin and PHP's proc_open(). Start the process with a command such as wkhtmltopdf --title "$SUBJECT" -q /dev/stdin $OUTPUTFILE and pipe the HTML you've got in your variable into the running process.


1

Sudo isn't the right tool for this job. It controls what commands you can run, not what files you can access. The right tool for the job is file permissions, with access control lists if the Unix traditional user/group/other permissions aren't enough. Create a group, let's call it webroot, and make it own the directory /var/www/html and the files in there. ...


1

As the other answers have stated: Yes, the file can be edited/modified.  And, at the risk of splitting hairs, allow me to point out that the question says … he has [write permission] on a file under [the directory]. and to make the semi-obvious comment that, to edit a file in the traditional meaning of the word, the user must also have read permission ...


1

Yes, the file can be edited. As far as the directory is concerned, the file can not be edited if you remove the execute permission on the directory for the target (owner/group/others). EDIT: If you want the owner to not be able to edit the file by changing the permission of the directory (assuming the same user owns the directory and file), then you can ...


0

You do not need to have write permissions to the directory, but the executable x bit has to be set. So, consider a direcory foo with a file bar. If permissions are set up as drwx--x--x foo -rw-rw-rw- foo/bar for example, write access is available to anyone as long as the x bit is given. Not even read-access r to the directory is required.


0

grep -r --include "httpd.conf" "10.22.0.141" . | cut -d: -f3- |\ cut -d ' ' -f4 | sort | uniq -c


1

I had a similar problem when using rsync to backup my system to my server. I used: rsync -aAXSHPr \ -e ssh \ --rsync-path="sudo /usr/bin/rsync/" \ --numeric-ids \ --delete \ --progress \ --exclude-from="/path/to/file/that/lists/excluded/folders.txt" \ --include-from="/path/to/file/that/lists/included/folders.txt" \ / ...


1

For several years I've been using a script wrapper around vi that saves the files I'm editing. It does this at most once per day so that I don't end up with too many backup files. This is a simpler version of the script I use; perhaps it's useful for you too. Instead of running vi, you would run vib (vi with backup): vib() { local DATE=$(date ...


6

With a large enough value of 'undolevel', Vim should be able to undo the whole day's changes. If you quit Vim in between, you also need to enable persistent undo by setting the 'undofile' option. Vim captures not just a sequential list of commands for undo, but actually a tree of all changes. It also has several commands around undo (cp. :help ...


2

There are two possibilities: 1) You need to look at the owner/group permissions of the directory containing the file or directory you try to delete as that entry will be modified if a file (or directory) within it is deleted. 2) The account (group membership) of user xyz is modified but the user is not using a new shell and therefore the new group ...


2

Here the answers: root has always full access to files and directories. The owner of the file usually has them too, but this is not always true. For example: -r-xr----- 1 user1 users 199 Oct 14 18:42 otherfile.bin user1 is the owner; however he can only read and execute, but root still has full access (rwx) to the file. RUID is the Real User ID and it ...


0

ls doesn't do this. Its job is to report on file metadata (permissions, timestamp, etc.), not on file contents. But file itself does (combined with a shell wildcard to list all files): file * for the current directory, or file /some/directory/* in another directory. If you want to combine metadata and file content information, you can combine the ...


4

AFAICT, no. The problem is that the gzip process will create a new file and will free the previous (the unzipped) one, including a removal from the directory. If no other hard-link in the filesystem is pointing to the file it will get lost once the last file descriptor refering to it is closed. For the future you'd be advised to synchronize the access to ...


3

ls itself won't show this information. You can pipe the output of the find to file -f -, as follows: $ find /usr/local/bin | file -f - /usr/local/bin: directory /usr/local/bin/apt: Python script, ASCII text executable /usr/local/bin/mint-md5sum: ASCII text /usr/local/bin/search: ...


3

65534 is some kind of default/nobody UID & GID value. Your VPS provider made some sort of mistake when they copied over your container. For example they used rsync but failed to use its --numeric-ids option. The user IDs inside your container don't exist outside the container and some copy tools, upon seeing UIDs and GIDs that they can't resolve, revert ...


0

While rsync --checksum is the correct answer, note that this option is incompatible with --times, and that --archive includes --times, so if you want to rsync -a --checksum, you really need to rsync -a --no-times --checksum.


1

You could run this before adding the device to store the inital list in a file: ls /dev >~/a And then this after adding the device: ls /dev | diff -u ~/a - This should show you in what way the two lists of files differ. diff shows the differences between two text files, and flag -u changes its output format: lines added will be prefixed with a + ...


4

It's not possible because ctime is changed always if there is a change of mtime. Here is the explanation: Let's see from file perspective: ctime is the inode/file change time, it means that ctime is updated when the file attributes are changed, like changing the owner or the permission. mtime is the file modify time, it's updated when you modify the ...


-1

lsof can help to see the list of file. here is way to see the locked files. sudo lsof /var/lib/dpkg/lock


0

Files and directories which have ACLs are identified with a + sign at the right side of the permission mask ie.: -rw-r--r--+ To remove ACLs you should use chmod A- /usr/share/X11/app-defaults/XScreenSaver See also man ls and search for explanation of the -l argument and man chmod and search for A-


0

If possible, pick the same user IDs for the same users on both systems. Filesystems identify users by their numerical user IDs. If you mount the CentOS home directory on Mint, the filesystem records CentOS user IDs, but user IDs may have been assigned differently on Mint. Let's say your CentOS user ID is 500 and your Mint user ID is 1000, and Mint has no ...


0

You can can mount a Centos partition in Mint mkdir -p /mycentos/home mount /dev/sdaX /mycentos/home Where sdaX is the name of the partition If you don't know the partition names - but you will need to know which one it is fdisk -l


0

There's a fairly simple answer (although I don't know for sure whether it works on all versions of *nix); simply do chmod g=u * i.e., set the group permissions equal to the user permissions. This is documented in chmod(1): The format of a symbolic mode is [ugoa...][[+-=][perms...]...], where perms is either zero or more letters from the set rwxXst, ...


1

Try this: for file in $(find .); do perm=$(stat -c "%a" ${file}); echo chmod ${perm:0:1}${perm:0:1}${perm:2:1} ${file}; done Remember to remove echo


1

On a (recent for sed's -z) GNU system, you could do something like: find . ! -type l -printf '%m:%p\0' | sed -Ez '/^.?(.)\1.:/d;s/(.)(.)(.):/\1\1\2\x0/' | xargs -r0n2 echo chmod (remove echo when satisfied with the result). Note that it only addresses the r, w, x bits not the special ones. If you don't want it recursive: find . -mindepth 1 ...


2

Launch your process through strace: strace -fe open skype You will see the list of each open() syscall, that is every file (or connection) the processes opens during its life. Looking at currently opened file descriptors will not provide a log but only a "snapshot" of what the process accesses right now.


1

A safer approach (that can deal with file names with spaces, newlines and other odd characters) is to use find itself and its -exec action: -exec command {} + This variant of the -exec action runs the specified command on the selected files, but the command line is built by appending each selected file name at the end; ...


2

You can do this with perl, using the excellent XML::Twig module. Assuming I've understood you correctly, the basics task is copying the 'verse content' element from one file, and 'everything else' from another file, and making a new file. So: #!/usr/bin/perl use strict; use warnings; use XML::Twig; my %nkjv_content; sub extract_content { my ( ...


2

Don't use find for this. Besides requiring non-portable GNU extensions to make it work, it also has to stat() every file for which it searches. ls, on the other hand, can simply list the current directory's dentries out -1 per line while -quoting all non-printables with a ? question mark (to include \newlines), and appending a / for each directory listing. ...


2

Rather than parsing ls, you can use find: find . -maxdepth 1 -type f ! -name ".*" | wc -l This will find all files (-type f) in the current directory (.) except those beginning with a . (! -name ".*") and pass the result to wc to count the lines. To use it as a variable in your script: nfiles=$(find . -maxdepth 1 -type f ! -name ".*" | wc -l)


3

You should probably be using the Pheaders, not the Sheaders. There's usually far fewer of them, and they correspond directly to pieces of the file that get mapped into memory by the kernel's ELF loader. I'm forced to use the contents of /usr/include/elf.h in the following, as you example doesn't include Elf64_Phdr definitions. Elf64_Off p_offset; /* ...


4

There's a command called file that makes (good but not always perfect) guesses about the file type. One way to use that command could be: find your_web_pages_directory -type f -name "*.*" -print0 | xargs -0 file | awk 'BEGIN{FS=": +"}$2~/[Ff]ont/{print $1}' | xargs rm -- The find command looks for ordinary files with extensions (you may ...


1

rm deletes the files you tell it to. * expands to all files (including directories), so you're telling rm to delete directories, which it won't do. Most shells have no way to exclude directories from a wildcard pattern. Wildcard patterns only match files by name, not by type. You can use find instead. Zsh has glob qualifiers which can match files by type, ...


3

Ok, so you want to run a command in each directory in a directory tree — the current directory, its subdirectories, their subdirectories, etc. The first thing to do is enumerate the directories in question. With the find command, tell it to list only directories: find . -type d The command you want to run in each directory is gmic ./*jpg -gimp_montage ...


1

sort big-csv-file.csv | uniq > duplicates-removed.csv Note that the output file will be sorted.



Top 50 recent answers are included