Tag Info

New answers tagged

0

You can use fswatch, a portable tool which selects the appropriate event mechanism if available (Linux, Mac, *BSD) or just stat(2) elsewhere. I did not write it, but I use it. It's open source (GNU GPL). Example usage: fswatch -e '.' -i '\.end$' . | while read file do # Get rid of removed file events ls $file 2>/dev/null || continue echo ...


0

If this is something you need to do somewhat frequently, you will probably find it useful to have a script to do it. Following is a quickly assembled Bash script which can do the job: #!/bin/sh dir_str=$1 src_dir=$2 dest_dir=$3 ret_code=0 if [ ! -e $src_dir ] ; then echo "Could not find source directory $src_dir." let "ret_code += 1" fi if [ ! -e ...


1

mv path_to_example_dir/*_jony /jony


8

This is because files use up space in whole-block increments. So if your block size is 512 bytes and you have a small 100 byte file, the size it actually uses up will be rounded up to the nearest block - in this case 512. When tarring, because the result is a single file, that inefficiency is reduced since there is only one resultant file - the .tar file. ...


1

ls -d */ | while read d do echo $d done


2

Beware that choroba's solution, though elegant, can elicit unexpected behavior if no directories are available within the current directory. In this state, rather than skipping the for loop, bash will run the loop exactly once where d is equal to */: #!/usr/bin/env bash for d in */; do # Will print */ if no directories are available echo $d done ...


3

In this case scp will copy each source file to /home/me/logs, overwriting /home/me/logs with the contents of each new file. The result is that /home/me/logs will be a copy of the last source file in the list. All the other source files are lost. Oops! Regular cp warns and aborts in this case, at least!


3

Make sure you are typing in /usr/bin, not usr/bin. The latter means "look for usr/bin starting in the current directory." For example, if your current directory is your home directory (~), then it will look for ~/usr/bin. The former means "look for /usr/bin starting from the root directory." This makes sure that the search for usr/bin starts from the root ...


1

Yes, thanks to FUSE, which allows filesystems to be implemented by userland programs. There are many FUSE filesystems out there, implementing files stored as something other than sectors on a disk, including alternate views of existing filesystems, files on a remote machine, files in an archive, etc. You can use archivemount to mount a specific archive to a ...


3

As Christopher suggested, archivemount can achieve this. Permits writing of files and when unmounted, the .tar.gz file is automatically updated to reflect the changes. # ls -lh download.tar.gz -rw-rw-r--. 1 steve steve 3.1M Feb 16 2010 download.tar.gz # archivemount download.tar.gz /mnt # cd /mnt # find . -ls|head 1 3127 drwxr-xr-x 0 root root ...


1

Debian does not install anything into /usr/local, in the sense that official Debian packages are forbidden to touch that hierarchy. Also, Debian packages can assume absolute installation paths, so they may not work correctly if moved by hand (or by somehow tricking dpkg into installing them into a different hierarchy). On the other hand, software packages ...


0

If your shell support brace expansion: for the first increment: mv /path/to/0.{0..99} /path/to/newdirectory/ the second increment: mv /path/to/0.{0..99}5 /path/to/newdir/ note: change 0 and 99 from {0..99} with first and last digit of your increment.


0

The following little loop will list a count of all files (excepting symlinks) in child directories of . which exist on the same filesystem as the child directory. for d in ./* ./.[!.]* ./..?* do ! [ -h "$d" ] && cd "$d" 2>&3 || continue printf "%s:\t" "$d" find .//. -xdev -depth ! -type l | grep -c '^\.//\.' ...


-1

This is the directory structure I am using / --0.1 - file --0.2 - file --0.15 - file --0.25 - file --first - dir --second - dir Now, first I will move the 0.1 and 0.2 files into dir 'first' for f in `ls|grep '^0\.[0-9]$'`;do;mv $f first;done; Next I'll move the 0.15 and 0.25 into dir 'second' for f in `ls|grep '^0\.[0-9][0-9]$'`;do;mv $f second;done ...


2

For your specific problem you can use the length of the file names to distinguish them: mv ??? first mv ???? second If you want to solve this in a more general case you really want to use a language like Python or Ruby, where looping over files and basic arithmetic are sane.


0

try find * -print | awk -F/ '{c[$1]++;} END { for (c2 in c) printf "-%s -- %d\n",c2,c[c2] ;} ' where find from directory above the ones you want to sum up awk will count top level dir and file and sum up at the end.


1

Pure ksh93 solution: FIGNORE='@(.|..)' for dir in */; do a=( "$dir"/**/* ); printf "%s\t%s\n" "$dir:" "${#a[*]}"; done Result from /usr/src: linux-3.17.7-gentoo/: 561 linux-3.5.7-gentoo/: 517 linux-3.7.10-gentoo/: 505 linux-3.7.9-gentoo/: 513 linux-3.8.13-gentoo/: 551 linux-4.0.5-gentoo/: 1849


1

Will something like this suit your need: The path /boot is used for sample demonstration. Change it to the directory you need. for DIR in $(find /boot/* -maxdepth 1 -type d) do printf "%40s: %10d\n" "${DIR}" $(find ${DIR}|wc -l) done Output: /boot/grub: 282 /boot/grub/fonts: 2 ...


1

You could find the toplevel directories first, then use a second find, to count the number of files and directories within the toplevel directory: $ for dir in $(find . -maxdepth 1 ! -path . -type d | sort); \ do echo -n "$dir " && find $dir ! -path . | wc -l ; done ./adir 1151 ./anotherdir 140 ./623de41e44 280 ./examples 154 ...


0

You can try (partition is an example). sudo debugfs /dev/xvda1 use dump to write inode data to a file. sudo dumpe2fs /dev/xvda1 man is your friend, these should give you some ideas.


26

The tool to display inode detail for a filesystem will be filesystem specific. For the ext2, ext3, ext4 filesystems (the most common Linux filesystems), you can use debugfs, for XFS xfs_db, for ZFS zdb. For btrfs some information is available using the btrfs command. For example, to explore a directory on an ext4 filesystem (in this case / is dev/sda1): # ...


0

You can use your programming language of choice, open the directory as if it was a file and read bytes from the resulting file handle. That's not going to tell you much, though, since it will just be garbage (with a few recognizable strings in it) as long as you don't know how it's organized. How it is organized is pretty much an implementation issue for the ...


0

java-package is of course a better idea. For now, your problem can be related to permissions. chown <current_user>:<whichever_group> /opt/jdk/jdk1.8.0_05/bin/java where current_user is the user you want to run java with (can be root) and chmod -R 755 /opt/jdk/jdk1.8.0_05 And then try.


0

You'd be far better off using the Debian java-package package to install Oracle Java. It allows you to build a Debian package file from the Oracle Java binaries, a package that can be managed using the regular Debian tools (including update-alternatives). For Debian 8.x, the currently supported Java versions are (from here): Oracle ...


0

I ended up just writing to a file: find ~/dim_import/* -type f ! -name xdir | cut -d '/' -f 5-6 > files and then looping through the "files" file and creating the directories from that and then copying the files there. while read line; do fileDir=`echo "$line" | cut -d '/' -f 1` # get folder name fileName=`echo "$line" | cut -d '/' -f 2` # ...


3

q1) Doing a ls -ld show me a . - why ? When you give no arguments to ls, the default is to run the command on the current directory, also known as .. Normally that means listing the contents of the directory, but you have used the -d option which requests listing the directory itself, not its contents. So you get the information for ., the current ...


0

Since you already know how to filter the files, then use recursive copy: cp -R Or you could just use rsync with --prune-empty-dirs option. rsync --exclude='*xdir*' --prune-empty-dirs ~/dim_import ~/new Note: If you don't use trailing slash from source (like above's example) dim_import is also copied.


1

I suggest you --depend of your so-- fslint, duff, fdupes, dmerge, rmlint, rdfind --which both are able to find twins much faster than fdupes or dupseek. I'd execute: $ find /path -type f -printf "%p - %s\n" | sort -nr -k3 | uniq -D -f1


1

With find and cmp: find . -type f -exec sh -c 'cmp -s data.txt "$0" 2>/dev/null && echo $0' {} \; You might want to add some more criteria to limit find.


1

I suppose you are talking about fragmented directory blocks. While you create file/ directory , it goes in the parent directory blocks. With time, you create and delete the objects and this blocks become fragmented. This is called non-contiguous directory. There must be feature provided by file system to make them compact . look into the particular file ...


1

Here is a method that only uses POSIX shell features: find ~/dim_import/* -type f ! -name xdir -exec sh -c ' p=${1%/*}; d=${p##*/}; f=${1##*/}; mkdir -p new/"$d"; cp "$1" new/"$d"' -- {} \;


0

xargs should be available. You could use: find ~/dim_import/* -type f ! -name xdir | xargs -I {} cp {} new/{}


1

If this is something that needs to be checked on a regular basis, you could setup a cron job to create a digest of the md5 hashes of the files, something like echo > $digest_file; find $search_path -type f | xargs md5sum >> $digest_file Assuming this has been ran since your file was copied, find the hash of your known file first, then check the ...


1

myfile=/full/path/to/data.txt mysearchpath=/my/search/path/root/directory for file in $(find ${mysearchpath} -type f) do diff ${myfile} ${file} > /dev/null result=${?} if [ $result -eq 0 ] then echo "Identical file found at ${file}" fi done Although this is a very expensive way (computing resources wise, especially if you are sharing ...


1

Found the answer. Something was wrong with the linkage, as @JeffSchaller suggested. The solution is to run xfs_check to see that the links were incorrect, then xfs_repair to fix them. run mount to view the device name. Mine is /dev/mapper/vg3-lv3 umount /3 xfs_check /dev/mapper/vg3-lv3 which returned the following: link count mismatch for inode ...


-1

You tried to verify that the attributes of the folder / directory have the attribute "i" - imutable is active! Check with the lsattr command to verify that the folder / directory has the attribute "i" activate if you turn it off with "* chattr -i 'folder' *" With this you can perform the task you want.


2

With GNU find and GNU coreutils, and assuming your directories don't have newlines in their names: find ~/foo -mindepth 1 -maxdepth 1 -type d -exec du -ks {} + | awk '$1 <= 50' | cut -f 2- This will list directories with total contents smaller than 50K. If you're happy with the results and you want to delete them, add | xargs rm -rf to the end of the ...


8

Looks like you might be looking for chroot. Note that while something like ../../../../../.. will not escape the restricted root directory, there are other ways to escape indirectly, by leveraging other processes. If you're concerned about a malicious application, run it as a user who doesn't run any process outside the chroot. For a more ...


1

Posting comment as answer: for d in directory_*; do cp -R "$d" "tmp_$d"; done Credits @drewbenn


4

For files which are not device that is not the minor number but the size in bytes. The size of a directory depends on which filesystem is used, and how many entries (i.e. files or subdirectories) are in it.


2

Those are not minor numbers (as they are for the device nodes). This answer explains each field in turn.



Top 50 recent answers are included