Operating on a directory and its subdirectories, recursively.

learn more… | top users | synonyms

1
vote
2answers
38 views

How to find number of Subdirectories under a given directory

In windows you get a count of the number of subdirectories within a directory.Is there any equivalent on Linux ? I'd like it to count recursively & Not stop at a single level.
4
votes
1answer
111 views

Why doesn't inotifywatch detect changes on added files?

I'm trying to monitor my /tmp folder for changes using inotifywatch: sudo inotifywatch -v -r /tmp After creating couple of files (touch /tmp/test-1 /tmp/test-2), I'm terminating inotifywatch (by ...
2
votes
2answers
37 views

rsync with colons in filenames

I have a fairly large directory that I need to sync to an external hard drive for both backup and portability reasons. /work I try to run the following rsync command in order to copy this folder to ...
0
votes
2answers
58 views

Different sizes after copy [duplicate]

I would like to copy for backup porposes a Linux user home directory with several GBs of data and the usual configuration files. The source directory and the backup directory should exactly have the ...
20
votes
2answers
1k views

How does rm -r go about recursively removing? In what order?

Is there some order of operations to rm? I performed rm on a large directory and am curious where I should look to see what might have been deleted. Does rm work on files first, then directories? Or ...
1
vote
1answer
81 views

Exclude hidden subdirectories from grep -r

I have a svn local copy, i want to make a search on the string some_string. $ grep some_string * -r lang/en:some_string=Some string lang/.svn/en:some_string=Some string But if a go little further, ...
3
votes
1answer
131 views

Finding largest file recursively

I am trying to find the largest file in a directory recursively. If there is a subdirectory inside of that directory the function needs to go inside that directory and check to see if the largest file ...
0
votes
2answers
47 views

check two partitions by selecting random files and running sha1 hashes on two files of each partition

A previous answer to a post mentions to run sha1 hashes on an images of a dd drive clone image. Another answer to that post suggests mounting the dd image an then compare if the sha1 hashes of ...
2
votes
2answers
48 views

Wildcard for arbitrary depth

I want to use grep where paths are arbitrary depth under the directory /path/to/dir and has the file name foo. I thought that the wildcard for arbitrary depth is **, and I tried grep some_pattern ...
1
vote
2answers
86 views

Change file ownership, based on previous owner

I am a moderately new linux user. I changed my PC, and started using CentOS 7 from CentOS 6. So I attached my previous hard disk to my new pc to take backup of my files. Now, copying the files (and ...
1
vote
2answers
158 views

I accidentally GZIPed a whole bunch of files, one by one, instead of using tar(1). How can I undo this mess?

I'm new to the gzip command, so I googled some commands to run so I can gzip an entire directory recursively. Now while it did that, it converted each of my files to the gzip format and added .gz to ...
0
votes
0answers
22 views

How to be certain “cp -n -r /dir/ /des/” does not overwrite files.. and is doing its job ? verbose mode?

I run the command cp -n -r /dir/ /backup/ but there is no way to tell what it is doing.. if it is skipping files that already exists.. if it is doing anything.. I tried adding -v option to ...
19
votes
4answers
1k views

The difference between -r and -R

It often happens that I want to apply an operation recursively. Some commands, such as grep, use a lowercase r to indicate recursion. For example grep -r foo . Other commands seem to prefer an ...
13
votes
2answers
1k views

Why doesn't recursion go upwards with rm?

I'm wondering about direction of recursion in general and rm specifically. rm recursion only works downwards correct? Running: sudo rm -R *.QTFS will delete all *.QTFS files in current directory ...
1
vote
1answer
95 views

Apply recursive chmod to files or folders only

I'd like to apply chmods to files and folders in one line, Basically: chmod 700 ./* -R # but only apply to folders chmod 600 ./* -R # but only apply to files Of course I searched google and read ...
1
vote
2answers
41 views

How do I find a files directory?

I am looking for a specific file in OS/X. I can see the file by using: ls -alR | grep "mkmf.*" This shows my that the file exists. How do I find what directory the file is located. Many thanks ...
0
votes
2answers
59 views

Copy directory not just the contents

I want to copy a directory into another directory. For example, cp -r dir1 dir2 copies the contents of dir1 into dir2. I want to copy dir1 itself into dir2 so that if I ls dir2 it will output dir1 ...
2
votes
3answers
76 views

How can I use wget to create a list of URLs from an index.html?

So wget has an ability to recursively download files, however it does it one file at a time. I would like to pass in a directory URL, and for each URL it encounters in the recursion for it to spawn ...
3
votes
6answers
507 views

ls content of a directory ignoring symlinks

I have a directory in which I would like to list all the content (files and sub directories) without showing the symbolic links. I am using GNU utilities on Linux. The ls version is 8.13. Example: ...
3
votes
3answers
161 views

How can I use rename to recursively rename everyting to uppercase

I'd like to recursively rename all files and folders (sub-folders) to uppercase. I found some scripts that will do it to lowercase, but I don't know how to change them so it will do it the other way ...
0
votes
3answers
215 views

bash script calling itself with different arguments

I just can not get it right. Script takes two arguments, target and command. Valid targets are specified within an array. If target is 'all', script should iterate through all targets. #!/bin/bash # ...
2
votes
1answer
372 views

How do I use grep to find a text string in files in sub folders of a parent folder without -r switch

I'm using Solaris 10 and have two grep versions one in /usr/bin and one in /usr/xpg4/bin. I have been searching for an answer on how to search for text within files within sub folders of a parent ...
9
votes
4answers
1k views

Recursively iterate through files in a directory

Recursively iterating through files in a directory can easily be done by: find . -type f -exec bar {} \; However, the above does not work for more complex things, where a lot of conditional ...
3
votes
2answers
493 views

Read all files in folder and subfolders - progress and size

Command I have is: time find . -type f -print -exec cp {} /dev/null \; This command finds all files in current folder and subfolders, print the name of each file and copy each of them to /dev/null. ...
2
votes
0answers
66 views

One way diff between 2 directories

I am looking to perform a diff between 2 directories, both of which contain may files and subdirectories. I am hoping to perform a one-way diff between a source and target directory that will return ...
5
votes
2answers
327 views

Remove Linux directories containing ONLY old files

We have numerous directories that each contain 2 files, one of which is a hidden file. We want to remove all those directories and their contents that contain ONLY files that have a modification date ...
1
vote
2answers
29 views

Install-on-Demand Wrapper Function for Executables

How do I make the following function work correctly # Install git on demand function git() { if ! type git &> /dev/null; then sudo $APT install git; fi git $*; } by making git $* ...
2
votes
1answer
140 views

Recursively find and move corrupted PDFs

The Issue I was using python-skydrive to download files to my PC, and I accidentally corrupted a good amount of my PDF files. When I try to view them in Document Viewer, I get the following error ...
2
votes
3answers
312 views

setting environment variable as a function of another env variable [duplicate]

I would like to set an environment variable (that we'll call "TEST") to store the path to a sub-directory of my home directory : something like /home/myself/dir/. I would like to use the $HOME ...
2
votes
2answers
33 views

Search for files by content only in trunk subdirectories

I think its a simple question, but the answer is probably a little more complicated :P Edit: Actually, its not complicated at all!^^ So I have a directory with multiple svn projects and I would like ...
3
votes
2answers
321 views

Moving large numbers of files and directories to a different directory

I'm trying to move the following move a large number of files that exist in the following structure to a /mnt/originals but I need to maintain the structure at the same time. I know cp would be a ...
7
votes
3answers
2k views

Delete files and directories by their names. No such file or directory

I need to delete all compiled data: directories called build, directories called obj, *.so files. I wrote a command find \( -name build -o -name obj -o -name *.so \) -exec rm -rf {} \; that ...
0
votes
1answer
29 views

Finding all kinds of extensions referenced in a html file

Here is my problem statement : There is a folder with many html and text files. I need to recursively go through each one of them and find all kinds of file extensions referenced in these html/text ...
0
votes
1answer
823 views

Delete all 'nohup.out' within a directory recursively

How can I delete all 'nohup.out' files within a directory recursively from my terminal? I'm using CentOS.
1
vote
1answer
101 views

ls recursive on home dir only with no flags specfied other than color [closed]

Like the topic says whenever I am in my home directory and run ls it shows me every file in every folder recursively, I cannot find any documentation of why this would happen, I have been looking on ...
1
vote
1answer
2k views

Does rm -rf * delete files recursively from the current directory or parent/root directory?

I wanted to delete files and folder recursively from a particular folder so I ran this command from that folder rm -rf * I assumed it would delete all files/directories under the current directory ...
5
votes
5answers
791 views

How to search in specific files matching a pattern

How can I find a word in specific files matching a pattern. e.g. searching for version in CMake* files recursively found in the current directory.
3
votes
4answers
1k views

How to zip recursively all subdirectories that only contain text files

I have a backup from a disk that contains data files and analysis. The dir structure and names are not really consistent. To save space, I would like to zip all the subdirs that only contain data ...
0
votes
2answers
651 views

Using `ls` recursively without -R

I am trying write a shell script that has output similar to ls -R without using the option -R. This is part of a programming assignment that forbids me from using -R, find and du. I need to identify ...
5
votes
4answers
2k views

Copying specific subfolders with directory structure to a new folder

I am having a the following directory structure: Main_Dir | ----------------------------------- Subdir1 Subdir2 Subdir3 | | ...
1
vote
2answers
557 views

How to exclude hidden files in recursive chmod?

I am having to do chmod -R 755 some_dir where 'some_dir' contains '.git' folders. Is there any way I can exclude hidden files and folder when doing recursive chmod? Note: chmoding .git folder is ...
2
votes
1answer
238 views

Merging folders with practically the same name but different casing

When digging around in the advanced settings in Dropbox I lost a folder. I only discovered this about a month later. I managed to get this folder back from Dropbox however the file structure of the ...
5
votes
3answers
1k 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 │   └── ...
3
votes
2answers
2k views

recursive delete with sftp?

I have a host that I can only access with sftp, scp, and rsync-- no ssh. I have a large tree of directories that I want to delete, but my sftp client apparently does not support recursive rms or ...
0
votes
1answer
104 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!
1
vote
2answers
1k views

Removing specific files recursively using rm or something simple?

I have a root folder with a text file in it called pairs.txt. Within that root folder are other folders with text files called pairs.txt in them. Is there a simple way to remove them using rm? I ...
2
votes
3answers
659 views

clone root directory tree using busybox

I have an TI DaVinci-based (ARM architecture kin to OMAP) system which netboots using TFTP and NFS-mounted root filesystem, and am trying to make it boot standalone without a netboot server. The ...
3
votes
1answer
863 views

How to download all html files from a URL's directory with wget?

I'd like to use wget to download a tutorial in a website, but this tutorial is in a specific directory. Suppose the URL is the tutorial main page http://www.abc.com/aaa/bbb/ccc/index.html. But the ...
1
vote
3answers
2k views

Count number of lines with a certain value in a column for all files in directory recursively

I have 40 files in a directory and I want to count the number of times there is a line with a "2" in the first column in each file individually. I am trying something like this, but it prints out ...
3
votes
2answers
2k views

How do I run a command on multiple files

This is pretty basic, I have a folder with several subfolders of JS files and i want to run Google's Clojure compiler on all of the files in those folders. The command to process a single file is as ...