Operating on a directory and its subdirectories, recursively.

learn more… | top users | synonyms

1
vote
3answers
31 views

Run a command over directories with name recursively

I have the following directory structure in AIX. codeRepo/REPO1/AREA1/objects codeRepo/REPO1/AREA2/SUBAREA1/objects codeRepo/REPO1/AREA2/SUBAREA2/objects From codeRepo I want to run chown myUser * ...
3
votes
3answers
154 views

Recursive Function not Working

I know that this is a ridiculous idea, but I'm trying to get a script to work that branches through every directory on the file system. The file's name is "Everywhere.sh". Here's the code: ...
-3
votes
1answer
24 views

Why wget is not willing to download recursively?

The command $ wget -r http://www.comp.brad.ac.uk/research/GIP/tutorials/index.html only downloads index.html and robots.txt for me, even though there are links in it to further pages in the same ...
1
vote
1answer
13 views

wget for recursive download of dxf files

There is a web server with many dxf type files which can only be downloaded one at a time. I thought it should be a good idea to use wget to download all of those files at the same time. ...
6
votes
3answers
253 views

Flatten the output of a recursive directory listing

Is there a way to list out all the files within a directory tree in a single list, sorted by modification time on Linux? ls -Rlt lists out files recursively, but they are grouped under different ...
3
votes
2answers
63 views

Find files recursively, but choose largest from among those with duplicate names

Given a nested directory structure containing various files, I would like to find all the files within it, but where there are multiple files with the same name, I'd like to return just the largest ...
1
vote
2answers
38 views

Create symbolic link recursively, if file 1.JPG exists rename it to 1A.JPG

I have a shell script for creating symbolic links of all my photos from one year. The photos are from different cameras and are in subdirectories. f=$(pwd); export f; q="2015/"; z="2015_Links/"; find ...
1
vote
1answer
68 views

How to find all files containing a specific string recursively on a BusyBox 1.4.2?

How to find all files containing a specific string within directory and all subdirectories on a BusyBox v1.4.2? I need to find string "AA:CC:DD:00:EE:55" or "AACCDD00EE55" BusyBox v1.4.2 (2012-06-01 ...
3
votes
1answer
34 views

Recursive find/replace, taking directory depth into consideration

I've had good luck doing basic find/replace: find . -name "*.php" -exec sed -i -e "s/<?php include 'http:\/\/www/<?php include '..\//g" \{\} \; I am wondering if there is a way to achieve a ...
2
votes
1answer
67 views

Recursively execute imagemagick composite command in directory tree

I have a large directory tree with many sub-folders and lots of images within each one. I found a script that applies watermark to all images within a directory, in-place, overwriting the original ...
0
votes
1answer
130 views

Copy all files matching criteria on find command with -exec

Below are my attempts at copying all files except .out and .class files into a subdirectory titled homework21/. Note homework21 is a subdirectory of the folder in which I am working in. ...
1
vote
1answer
249 views

Recovering from a chown -R / [duplicate]

I've made today the greatest error on my server using root user: chown -R 33:33 / instead of chown -R 33:33 . within some webroot folder. Well, this brought ssh down. I made it this far to get it ...
27
votes
6answers
990 views

How to copy a folder recursively in an idempotent way using cp?

When I use cp -R inputFolder outputFolder the result is context-dependent: if outputFolder does not exist, it will be created, and the cloned folder path will be outputFolder. if outputFolder ...
1
vote
2answers
69 views

List files in hierarchy of directory

I need to list files in hierarchy of directory. For that I wrote script like foreach file ( * ) ls ${file}/*/*/*/*/*.root > ${file}.txt end But for this I have to know that in the directory ...
0
votes
2answers
90 views

Recursive rm doesn't work for me

Suppose, we have the following files in a directory: test.txt test.txt~ /subdir test1.txt test1.txt~ When I run rm -r ./*.*~ inside top dir only test.txt~ is removed. Why doesn't it perform ...
1
vote
2answers
88 views

copy recursively skipping directories with specific name

I have a directory with ~100 Gb. I need to copy this directory to other place skipping specific folders (there is a lot of them). The following is a wrong code to demonstrate my needs. $ cp -r ...
3
votes
3answers
264 views

Bulk remove a large directory on a ZFS without traversing it recursively

I want to remove a directory that has large amounts of data on it. This is my backup array, which is a ZFS filesystem, linear span, single pool. The data is in this pool called san, mounted on /san ...
2
votes
2answers
186 views

remove whitespace from all items in a directory and sub directory

I have a directory which contains files and sub directories, some of which have whitespace in their names. Further more each of these sub directories contains files with whitespace in their names. Is ...
3
votes
2answers
146 views

Recursive copy files with rename

If I have input folder files_input that has subfilders like 01-2015, 02-2015, 03-2015 etc and all these subfolders have other subfolders. Each subfolder has only one file called index.html. How can ...
2
votes
3answers
2k views

How to I copy the directory and subfolders but ignore certain files in the subfolder?

I believe the question is best asked with an example. /home test1.txt test2.txt /home/my-folder test3.txt test4.txt test1.txt, test2.txt and my-folder folder are inside /home. ...
3
votes
2answers
222 views

File deletion under special conditions, recursively if possible

I am looking for a unix command sequence, which is able to perform a quite complex, conditional deleting action. All files with the extensions "[NAME].cut" and "[NAME].cut.bak" shall be deleted, IF ...
4
votes
2answers
342 views

How to recursively check if a specfic user has read access to a folder and its contents?

I need to pass a user and a directory to a script and have it spit out a list of what folders/files in that directory that the user has read access to. MS has a tool called AccessChk for Windows that ...
1
vote
0answers
106 views

Create tree of processes

I'm implementing pstree as an assignment, and I would like to create test tree of processes, but I'm struggling to do so. I tried to do something like this to create tree of background processes ...
9
votes
3answers
1k views

How to copy a directory recursively using hardlinks for each file

I want to create a "copy" of a directory tree where each file is a hardlink to the original file Example: I have a directory structure: dirA/ dirA/file1 dirA/x/ dirA/x/file2 dirA/y/ dirA/y/file3 ...
2
votes
2answers
110 views

Efficient search of unique owners of files and directories

I would like to view the unique owners of all the files and directories underneath a certain directory. I have tried: ls -ltR <dir-path> | grep -P '^[d|\-]' | awk '{print $3}' | sort | uniq ...
2
votes
2answers
165 views

List files recursively in Linux CLI with path relative to the current directory, max 250 char

I'm trying to list all the files with names no longer than 250 characters (including the directory it is part of, from the relative path my command is inside). I've seen a similar thread , but that ...
0
votes
1answer
72 views

How do you combine -r and -c for gunzip?

I am trying to recursively gunzip files (-r) but don't have permission in their original location to store them. I know to change the location for a single file you do gunzip {file} -c > {new file ...
0
votes
1answer
133 views

How do I copy all files that have been created or modified in the last 12 months?

I would like to copy all the files created in the last 12 months to a new folder leaving behind everything else. Including sub folders.
6
votes
4answers
461 views

Converting `for file in` to `find` so that my script can apply recursively

I've been working on my first bash script for some time now (I just started UNIX this week). I have this idea of running a bash script to check some conditions and using ffmpeg to convert all the ...
3
votes
7answers
869 views

How to copy a folder structure and make symbolic links to files?

I have a folder SOURCE that contains several sub-level folders, each with its own files.. I want to copy this folder in a new folder COPY where I need to copy the directory structure but keep the ...
3
votes
3answers
178 views

remove all instances of _000 from multiple files

Had to recover my music library from a HDD which died.... got everything I wanted but all music track names have _000 added at the end. I really don't fancy going through 8000 individual music tracks ...
1
vote
1answer
64 views

Recursively list files containing an underscore in the file name

I have a large directory with tons of files and subdirectories in it. Is there a way to recursively search through all of these files and subdirectories and print out a list of all files containing an ...
0
votes
1answer
31 views

Rename and copy/move sets of similar named directories to another location

For a set of directories with similar names at different location, /foldX/dirA with sub-directories aa1 aa2 aa3 aa4 aa5 /foldZ/dirA with sub-directories aa1 aa2 aa3 /foldY/dirA with ...
2
votes
3answers
54 views

Set group permissions as owner permissions

I need to set the same permissions of owner to group recursively to all elements in a directory.
2
votes
2answers
230 views

Run a command with wildcards in each subdirectory

I use this command to make a montage of all the images in a directory: gmic *jpg -gimp_montage 4,\""V(H(0,1),H(2,V(3,4)))"\",1,1.0,0,5,0,0,0,255,0,0,0,0 -o -0000."$(date)".jpg I want to run this ...
0
votes
1answer
324 views

grep recursively in ksh on AIX [duplicate]

How do I grep recursively in directories and sub directories in ksh on AIX? I have tried grep -r but this is not available.
26
votes
6answers
35k views

How do I grep recursively through .gz files?

I am using a script to regularly download my gmail messages that compresses the raw .eml into .gz files. The script creates a folder for each day, and then compresses every message into its own file. ...
-1
votes
1answer
134 views

How can I recursively grep through several directories at once?

I use grep -r all the time to find occurrences of a string within files in a given directory: $ grep -r "string" app/assets/javascripts > app/assets/javascripts/my_file.js: this line contains my ...
3
votes
1answer
461 views

Triple dot wildcards

I have a very large directory structure of source code that is very difficult to work with. I would like to run a tool to transform it to a Maven like structure that works better for me. When I have ...
5
votes
1answer
2k views

rsync recursively with a certain depth of subfolders

I want to rsync a folder recursively but want subfolders included only to a certain depth. For example I would want a depth of 1,2,3 or 4 subfolders like this: source/ ├── subfolder 1 │   ├── ...
-2
votes
2answers
620 views

Can I copy multiple directories into a single directory with a single command?

I have used photorec to recover data from a HDD and now have many directories /home/ray/recup_dir.1, to /home/ray/recup-dir.598 taking up valuable space in my Home directory. I want to copy them ...
3
votes
1answer
225 views

Copy only file details (file name, size, time) from remote machine in unix

how can we copy only file details (filename, size, time) from a remote machine in Unix? For example: I have a directory (/opt/apache/…/webapps/Context) placed on a remote machine. Now I want to copy ...
1
vote
3answers
58 views

Moving files recursively if certain condition is met

I have the following directory tree: records/13/2014.12.16/00/05.mpg records/13/2014.12.16/00/15.mpg records/13/2014.12.16/01/05.mpg records/13/2014.12.16/02/15.mpg records/15/2014.12.14/05/25.mpg ...
1
vote
2answers
3k views

How to find number of Subdirectories under a given directory [duplicate]

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.
6
votes
1answer
4k 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
404 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
1k 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 ...
22
votes
2answers
2k 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
1k 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, ...
6
votes
1answer
7k 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 ...