A file system structure in which to store computer files.

learn more… | top users | synonyms

1
vote
1answer
40 views

for + array + args

I have problem with my for cycle, this is what I want: for arg do array[index]=(`find $arg -type l -maxdepth $depth -printf "%p\n" `) index++ done fi arg - positional arguments, only directories ...
1
vote
0answers
40 views

How can I specify an executable path that will work from any working directory? [closed]

I have a java process that runs in this directory: /home/zookeeper/zookeeper-3.4.5/org/zookeeper/Process.class That Java process will in turn launch another Java process that lives here ...
1
vote
2answers
159 views

Count entries for each directory in tree

Say I have the following tree: root: d foo d bar /foo: d A - tmp.txt /bar: d B - tmp2.txt /foo/A: - tmp3.txt /bar/B: d = directory and - = file I need to answer the following question: which ...
3
votes
1answer
165 views

How can there be a directory named `~`?

I was trying to test out this buggy/new tool to see how it works, and it prompted me to choose a directory to use for stuff I am doing. From the directory ~/Code/indep, I typed in ...
5
votes
1answer
2k views

quotas not linked to users but to directories

Usually, quotas are enforced per user, as related to the proprietary of the file. Is it possible to apply a quota on a folder basis, in such a way, that a folder contents are limited in disk space?
1
vote
1answer
157 views

Find a particular nesting of directory names, e.g. …/project/dir1/dir2

I'm having some issues dealing with the find command; I don't know the syntax for it very well and I need to use it in a script to find a specific directory structure that could be located anywhere. ...
0
votes
0answers
26 views

Hard link for directories [duplicate]

I have a simple question about the difference between hard links and soft links. Why is it not possible to create hard links for directories in Linux?
3
votes
1answer
2k views

Extract single file from tar to other folder

I've searched for multiple forums for this questions and have seen different answers but so far, nothing have worked yet even from the ones I've seen here. I want to extract a single file from a tar ...
3
votes
1answer
104 views

Test for link with trailing slash?

I created in /tmp/test/ mkdir somedir ln -s somedir/ somelink I want to loop through only directories: for file in */ ; do if [[ -d "$file" && ! -L "$file" ]]; then echo "$file is a ...
0
votes
1answer
265 views

Extract a single file from a tar file and put it to another directory [duplicate]

I need to extract a single file from a tar file to another directory. So far I have this: This one extracts a single file to same directory: tar -xvf filename.tar ./file.txt I tried this but it's ...
-1
votes
1answer
143 views

Select a range of files from directory structure /year/month/date.db

I have databases stored in the directory structure year/month/date.db an example would be db/2013/10/15.db I need to be able to select a range of these with a script ("dbSelect ...
1
vote
2answers
129 views

Is there a problem if I add a non-existing path to `PATH` environment variable?

I have a following lines in my .bash_profile. if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" fi I think I found it somewhere in the internet. Is it also ok, if I write only ...
1
vote
3answers
70 views

Can tree be used to list the number of files per level?

As title, I need to look into a particular directory and list the number of files per level. The directory is pretty large, about 10-15 levels deep. For instance, if I have the following: D1 | |-- ...
2
votes
3answers
2k views

cp --no-target-directory explained

Question: I need a simple example of how to use cp --no-target-directory. I do experience some difficulties in understanding cp --no-target-directory. I do understand the explanation for mv ...
1
vote
2answers
2k views

Resetting user directory permissions etc [closed]

My "Linux mint Debian edition" installation worked well until I used a live-CD to boot and then copied some files back and forth to and between the hard drive and a usb device. Now it says that it is ...
1
vote
2answers
610 views

How to find certain files and move them to a new directory in the same command?

So I was looking around and all I have found is how to do this only if the directory is already made, which is this: find source -name '*.z' -exec cp {} destination \; But how can I make a new ...
2
votes
2answers
59 views

Directory permissions vs file permssions

If I have two users called john and sally. Both are part of the users group. john creates a directory with permissions 775. sally then puts a file there with 644 permissions. Even though the file ...
5
votes
3answers
864 views

Recursively add a file to all sub-directories

How do I recursively add(or touch) a file into the current directory, as well as all sub-directories? For example, I would like to turn this directory tree: . ├── 1 │   ├── A │   └── B ├── 2 │   └── ...
4
votes
1answer
761 views

How search for a file beginning with either a or z and ending with a or z?

I attempted find -name 'a*' 'z*' '*a' '*z' but it gave me the error code find: paths must precede expression: z* I know how to find files starting with a though z, or ending with a-z, but not ...
1
vote
1answer
123 views

How to change mountpoint name?

This question has been asked before, but because I have a few more doubts about the process. I am working in ubuntu, this is what df -h shows: Filesystem Size Used Avail Use% Mounted on ...
3
votes
3answers
460 views

How to create a short path?

We have so many useful folders, which are in different path, for our working in Linux. For example : $ cd ~/Documents/Courses/EDX/physics2013/ $ cd ~/Documents/Company/OpenGL/Proj/... $ cd ...
1
vote
1answer
356 views

Process owned by root can't write files

I'm running a program (syslog-ng) that must read and write several files in a given path. It was failing at start, claiming that it is unable to open a file in that path. Please, assume this ...
0
votes
1answer
90 views

Recursively Move All MP3's in a Directory [duplicate]

I have a lot of mp3 files located at various levels of subdirectories inside a single folder and I want to move them all to a single directory, what command could I use to do this? Thanks!
2
votes
2answers
719 views

Check recursively if directories in a path exist

I want to check recursively if directories in a given path exist; if they do not, I want to create them. So if I have the path /dir1/dir2/dir3/dir4, if want to check first if dir1/ exists, and if not, ...
1
vote
1answer
865 views

mount.cifs not respecting file permissions in Ubuntu 12.04.2 LTS

I am attempting to mount a cifs drive in standard Ubuntu 12.04.2 LTS using the following line in /etc/fstab: //server-name/share-name /mnt/archive cifs ...
3
votes
2answers
61 views

Is there a way to condense ../.. parts of a path out programatically?

Say for example I have these types of paths to files in a script: /path/to/some/file/../../file1.txt Is there a command I can call such as readlink that will convert this path to its actual ...
2
votes
2answers
608 views

\uFFFD character in directory name

I have a lot of directories with a \uFFFD (65533) character in it. The problem is that I can't really access this directory because of this character. For example I got a directory with the name: ...
6
votes
4answers
604 views

set read and write permissions to folder and all its parent directories

I need to set read and write permissions for root user to directory subfolderN and all its parent folders till root. I can do it by hands: $ sudo chmod +rx /root/subfolder1/subfolder2/subfolderN $ ...
23
votes
12answers
4k views

What's the most resource efficient way to count how many files are in a directory?

CentOS 5.9 I came across an issue the other day where a directory had a lot of files. To count it, I ran ls -l /foo/foo2/ | wc -l Turns out that there were over 1 million files in a single ...
2
votes
1answer
91 views

bash - inherit directory stack in children

If, in my newly created bash, I do: pushd foo pushd bar dirs -l -v I will get something like 0 bar 1 foo 2 old_dir If I then do bash dirs -l -v I get only 0 bar The same thing happens ...
3
votes
2answers
1k views

Automatically moving files to a directory, one by one, and only when the target folder is empty

Is it possible? And in reverse alphabetical order? Essentially, this: How can I move files by type recursively from a directory and its sub-directories to another directory? Except that each file is ...
3
votes
3answers
795 views

Merging two directory without copying the files

Let's say I have as follows : Folder A C1 file a A2 Folder B C1 B2 file b B3 What I want is to merge these two folders, which would give me : Folder C ...
1
vote
1answer
91 views

If I hardlink to a directory, will the contents be “preserved” as if I hard-linked to every file?

I've seen people on the internet talk about using hardlinks to force files to stay on disk as a backup, even if they're deleted in their original location. Would this work for a directory too? Why or ...
1
vote
3answers
285 views

Group+rx permission only in directories using ACL?

I need to install acl in order to set up a very specific permission structure. Group members should be able to see the files in a directory and change into the subdirectories. However, they should not ...
2
votes
2answers
477 views

In Linux, is 'make folder/path/clean' same as running 'make clean' command in folder/path?

I'm new to Linux, more so for Makefile. In Linux, is 'make folder/path/clean' same as running 'make clean' command in folder/path/? (folder/path/ refers to an arbitrary directory.) Apart from this ...
1
vote
2answers
1k views

Find and move directories based on file type and date

I have a directory "New Movies" containing 200+ subdirectories "Movie Name (year)". The subdirectories "Movie Name (year)" contains a single video file (avi/mkv) and several related jpg/xml files. I ...
0
votes
2answers
580 views

Delete all files except certain subfolder [duplicate]

I want to recursively delete all files not accessed in a while in folder a, except all files in the subfolder b. find a \( -name b -prune \) -o -type f -delete However, I get an error message: ...
5
votes
1answer
727 views

Why is this empty directory 3.5MB?

I've just read this question: What does size of a directory mean in output of 'ls -l' command? ...which doesn't quite answer my question. Basically, I'm moving files onto a NAS. The folders ...
3
votes
3answers
2k views

How to determine how many files are within a directory without counting?

I've been having a fairly serious issue on a high traffic web server. PHP pages are slowing down considerably, and it only seems to be an issue on pages where sessions are accessed, or a certain table ...
20
votes
8answers
19k views

How do I loop through only directories in bash?

I have a folder with some directories and some files (some are hidden, beginning with dot). for d in *; do echo $d done will loop through all files, but I want to loop only through directories. ...
4
votes
3answers
112 views

How to condense subdirectories

I have one directory with many sub-directories. All of those sub-directories contain files which each have unique names. I want to take all the files from all of the sub-directories and move them all ...
3
votes
2answers
162 views

Preventing accidental directory deletion. Making an alias that contains options?

I use an alias to prevent me from accidentally deleting files, and I would like to do something similar for directories. For files, I have the following added to my .bashrc: alias rm="rm -i" I ...
7
votes
1answer
292 views

Boot into a chroot?

I have Linux (Debian Jessie) installed on a hard drive. Drive - sda1, ext4fs, and sda2 - swap I have a /chroot folder. There is installed another system, in /chroot folder. Question: How to tell ...
1
vote
0answers
46 views

Directory size as reported by stat on NTFS

We all have seen gazillions of directory size reports from ls or stat. We know they don't mean real size of the content, but they do have meaning, but since the meaning is not very useful for normal ...
2
votes
1answer
354 views

Allow world access to directory under 0750 directory

I prefer to keep my /home/dotancohen/ directory as permissions 0750. However, I do need Apache to access /home/dotancohen/someProject/public_html/. I know that I could configure the home directory as ...
4
votes
2answers
58 views

List all directories that do NOT have a file with a given file name inside

How would I go into listing all directories that do not have a file with a given file name inside? e.g. given this tree / /a README file001 file002 /b README file001 /c ...
2
votes
5answers
189 views

List a directory but only if it contains sub-directories?

In Unix, is it possible to use one command ONLY to list directories if they contain a sub-directory? For example, I would like to list the directory name if it contains a sub-directory called ...
1
vote
3answers
84 views

Mode to set Directory in Only READ-WRITE mode

Can anyone tell me how to set a directory only in read/write mode as below? -rw-rw-r-- I tried with 640,644 but I am able to achieve...
3
votes
2answers
141 views

How to make directory modication date change when files from that dir change?

For example, if a file has been changed in that directory, then directory modification date should be updated. Basically any changes that happen in that directory should trigger a "touch" on the ...
0
votes
2answers
1k views

How to create nested directory in a single command? [duplicate]

Apparently, it's not possible to create a nested directory in a single command? $ sudo mkdir x/y/z mkdir: cannot create directory 'x/y/z': No such file or directory