Tag Info

New answers tagged

2

(cd /a && ./script1)& (cd /a/b && ./script2)& If the names don't contain spaces or special characters like *, (, or ), you don't need quotes.


1

Permission to remove and rename a directory is determined by its parent's permissions, not its own (just like other files). Just set the permissions on the directory to what you need and make its parent -w. Depending on your use case you may want to make the directory sticky +t as well - then users can't move around others' files, only their own.


7

use rsync: rsync -a --ignore-existing cosmo_sim_9 /dest/disk/cosmo_sim_9 --ignore-existing will cause it to skip existing files on the destination, -a will make it recursive, preserving if possible permission/ownership/group/timestamp/links/special devices. you can do it for all directories by using a bash for loop: for dir in cosmo_sim_* ; do rsync -a ...


10

Using rsync can accomplish this. Based on the type of system you have, you will need to donwload it: sudo yum install rsync (RPM Based) sudo apt-get install rsync (Debian Based) Then using this, here is the command you will need to use: rsync -a source destination Or rsync -r source destination Where -r stands for copying data recursively (but don’t ...


6

Directories are special in the sense that within a directory you can have references to several files and directories, so, if you remove the parent directory, all those files lose their reference point from where they can be accessed, the same with process. For such cases, rmdir() have different checks, that are different from unlink(): If the directory is ...


0

If you are using a GPT partition table, there are two labels involved and different filemanagers may show either label: Partition Label parted /dev/sdb name 1 MyBook will rename the first partition on /dev/sdb to MyBook. Filesystem Label e2label /dev/sdb1 MyBook will rename the filesystem label on ext2/3/4 installed on /dev/sdb1. Different utilites ...


2

These are backup files that gedit creates by default. You can disable this feature by going to Preferences → Editor and unchecking the line Create a backup copy of files before saving


3

I guess its pretty clear from the Man pages. And by the way what is your question? What part of the man page is not clear to you? With the execute bit set you have the permission to cd into the directory Also for long listing ls -l i.e. to view the meta data of the files inside the directory (Provided that read permission is there for the directory.


1

The rmdir does not provide an -i flag like rm command does when you want to confirm a deletion of a certain directory. However, rmdir returns an exit code of 0 when it operates on an empty directory. For example: $ mkdir emptydir && rmdir emptydir && echo $? 0 As you can see, it does not ask us for confirmation when deleting an empty ...


1

This is a job for rsync. There's no benefit to doing this manually with a shell loop unless you want to move the file rather than copy them. rsync -a /images/ /images2/ If images with the same name exist in both directories, the command above will overwrite /images2/SOMEPATH/SOMEFILE with /images/SOMEPATH/SOMEFILE. If you want to replace only older files, ...


0

for dir in images2/*; do mv "$dir"/* "images/$(basename "$dir")"; done Loop over all the contents of images2 using an expanded glob (to avoid the problems with parsing ls) then mv the contents of those items to the matching entry in images. Uses basename to strip the leading images2 from the globbed path.


1

@inulinux12 , you can use the following one line for loop from command line: $ for dir in images2/*; do mv "$dir"/* "${dir/2/}"; done This will move all of the files from images2 to images in their respective directories. Note: this assumes no files have the same name. For example: Before execution: $ ls -R images* images: ad adfoo fe images/ad: ...


2

@Praveen J Kumar , I'm not so clear, so I'll try to cover the basics. There are four cases here: You do want to get prompt when deleting a directory. -i flag is for interactive session, and will ask you before each file is deleted. -r is for recursive, i.e. go over the entire directory and sub directories etc.... Then use: $ rm -ri <directory path> ...


1

Look at the manual for cp (also mv): cp [OPTION]... [-T] SOURCE DEST cp [OPTION]... SOURCE... DIRECTORY cp [OPTION]... -t DIRECTORY SOURCE... If you do cp a b then if b does not exist you get cp -T a b, but if b exists and is a directory you get cp -t b a, else error. Example mkdir empty cd empty mkdir a touch a/a-file cp -r a b #this creates ...


1

Just do as you did: cp -r dir1 dir2 and you will have dir1 (with its content as well) inside dir2. Try if you don't believe ;-). The command that would copy content of dir1 into dir2 is: cp -r dir1/* dir2


0

To actually just create a file, you can use touch with find: $ find . -type d -exec touch {}/file \;


1

Your understanding is pretty much correct. A better way to think of the execute permission is that it allows you to do things with a file or directory name in the directory (other than just reading the name itself). Most of those things involve translating the name to an inode, but it also includes creating new names and removing existing names. Write ...


0

From this answer, I can think of this one as a possible solution. /* * List directories using getdents() because ls, find and Python libraries * use readdir() which is slower (but uses getdents() underneath. * * Compile with * ]$ gcc getdents.c -o getdents */ #define _GNU_SOURCE #include <dirent.h> /* Defines DT_* constants */ #include ...


0

ls -1 | wc -l comes immediately to my mind. Whether ls -1U is faster than ls -1 is purely academic - the difference should be negligible but for very large directories.


0

Probably the most resource efficient way would involve no outside process invocations. So I'd wager on... cglb() ( c=0 ; set -- tglb() { [ -e "$2" ] || [ -L "$2" ] && c=$(($c+$#-1)) } for glb in '.?*' \* do tglb $1 ${glb##.*} ${glb#\*} set -- .. done echo $c )


4

It did that because . isn't a name that can be used to create a subdirectory. cp -a . ~/xyz copies ./file1 to ~/xyz/./file1, ./file2 to ~/xyz/./file2, etc. But ~/xyz/./file1 and ~/xyz/file1 are the same, so the effect is to copy the contents of the current directory to ~/xyz. You can see this if you add the --verbose option to cp to display each pathname ...


0

find / -newerct ` date +"%D"` -name cy This find cy that was changed (or created) after midnight. the newerXY params: c = change time of the file(you can also try 'B', for birth time but it's not supported on all platforms) t = date format to compare with. Very flexible :) try man find for more information about newerXY


0

for the last 24 hours find wherever -name cy\* -ctime -1 -print If there is no file begining witch cy in wherever, you may avoid backslashig *. since midnight find wherever -daystart -name cy\* -ctime -1 -print Hope this help.


0

Now that you have clarified your question, here is an answer that should meet your clarified question: touch -t `date +%m%d0000` /tmp/midnight find / -type d -newer /tmp/$$ -name cy rm /tmp/midnight


1

$ TODAY="cy`date '+%Y%m%d'`" $ find / -name $TODAY To see the contents of $TODAY: $ echo $TODAY $ cy20140806 If you just want it in YYMMDD format, then: $ TODAY="cy`date '+%y%m%d'`" $ find / -name $TODAY $ echo $TODAY $ cy140806 This works for me on Solaris 10. On your system, it may be different. Run a man date to see the options for your system.


0

The rows of ? characters indicate directory entries that don't correspond to a file. This is a sign that your filesystem is damaged. You won't be able to call rm to remove these files because the files are not actually there, there's only a dangling label. You need to run a filesystem check and repair (fsck). Given that this is on your root partition, as ...


3

The answers given until now do not take into account that the file list passed from find to du may be so long that find automatically splits the list into chunks, resulting in multiple occurences of total. You can either grep total (locale!) and sum up manually, or use a different command. AFAIK there are only two ways to get a grand total (in kilobytes) of ...


1

If the list of files is too big that it can't be passed to a single invocation of du -c, on a GNU system, you can do: find . -iname '*.jpg' -type f -printf '%b\t%D:%i\n' | sort -u | cut -f1 | paste -sd+ - | bc (size expressed in number of 512 byte blocks). Like du it tries to count hard links only once. If you don't care about hardlinks, you can ...


3

Probably not, though this may have surprised the devs as well. Here's a comment from an excerpted GNU's ls.c: # /* Extensions only apply to regular files, apparently. */ Here is a link to the full ls.c source in which you will find the same, though it is not as pretty to read, maybe. It is worth noting though you can get some alternation in color for ...


0

Can't think of a way to expand the glob in -exec, but putting it in a subshell should work. find /data1 -name MyTargetDir -type d -exec bash -c 'shopt -s dotglob; rm -rv "{}"/*' \;


2

The only safe way is to Copy all the files to a different filesystem. Unmount the filesystem. Wipe the partition or volume containing the filesystem. This is the “hard-drive blaster” you mention in your question. Don't use dd, cat is just as good. You can do that remotely, unless this is the root filesystem, in which case what you want to do is impossible. ...


2

So you want to hide directory names... an experiment. # truncate -s 1G foobar # losetup -f --show foobar /dev/loop0 # mkfs.ext4 /dev/loop0 # mount /dev/loop0 /mnt/tmp # cd /mnt/tmp # mkdir collywobbles # sync # mv collywobbles shriggelfigs # sync # mv shriggelfigs flapjacks # sync # rmdir flapjacks # cd .. # umount /mnt/tmp So basically we have an empty ...


0

If OP is using Debian / Ubuntu or their variants, check out this Ask Ubuntu post, especially the secure-delete package in the recommended answer.


2

/etc/skel contains files to be copied to new user's home directories, therefore the names are, of course, the same as in an user's home directory. This explains /etc/skel/.bash_profile. The directory /root also is a home directory, namely the home directory of the user root. This explains /root/.ssh and /root/.config. /etc/.pwd.lock seems to be a lock file. ...


2

This might be a highly opiniated answer, but I think the main reason dot files and dot directories are marked like that is not to hide or obscure them - I think it's just to let the user know that within those files and directories are program's and user's settings that can be changed by them or by the programs themselves. The fact that dot files and dot ...


11

You've misinterpreted the primary rationale for "hidden files". It is not to prevent users from messing around with things. Although it may have this consequence for very new users until they learn what a "dot file" is (dot file and dot directory are perhaps more appropriate and specific terms than "hidden"). All by itself it doesn't prevent you from ...



Top 50 recent answers are included