Operating on a directory and its subdirectories, recursively.

learn more… | top users | synonyms

2
votes
2answers
25 views

Replace string in multiple files using find and sed

So I've arrived at the conclusion that for recursively replacing all instances of a string in directory (only for .java extensions files) I need to use find . -type f -name "*.java" -exec sed -i 's/...
0
votes
1answer
103 views

How to create directories containing index.html with wget --recursive?

I'm pretty happy how wget -r works and downloads the things. I have set up a localhost server which serves a website and the pages look like this: http://localhost:8080/ http://localhost:8080/foo ...
0
votes
1answer
36 views

counting recursively files and directories

I need some help for this : Let's say I am in a directory and in this directory there are other directories and files etc... I would like to use a recursive function to count all the files and ...
-2
votes
1answer
43 views

delete recursive subfolders with find

I need to delete recursive subfolders in a single line For one subfolder: find folder -name "subfolder" -exec rm -r "{}" \; or find folder -name "subfolder" -type d -exec rm -r "{}" \; But in the ...
1
vote
0answers
23 views

Recursively update all Folder “Date-modified” timestamps to date of newest file

I would like to recursively update the Date Modified field of a directory (and all its subdirectories) so that every folder has the same Date Modified timestamp as the most recently modified file that ...
-3
votes
2answers
62 views

Why rm does not work recursively by default?

I was discussing with a friend trying to figure out why rm command does not, for example, check if the path is to a file or a folder automatically and delete it recursively, by default, if necessary. ...
1
vote
1answer
39 views

Recursive bash function (directory iterator)

I know that my following task could be accomplished using simpler 'find' comment, but I am trying to implement a solution using a recursive call. I am looking through a specific directory and trying ...
1
vote
4answers
102 views

Renaming files recursively in sh

I use Synology as storage for films from CCTV cameras. After copying a file from the CCTV system to Synology, I convert it to the AVI format. So my files have names like this: 10.01.07-10.01.48[M][@0]...
1
vote
1answer
24 views

Recursively compare directories with summary on different contents without examining file contents' differences

I want to compare the contents of two directories, recursively, showing which files are missing from one or the other, and which files have different content. But I don't want output on the ...
3
votes
1answer
43 views

Copy only files and only lines containing a string while preserving directory structure

Say I have a directory that contains other directories and files. I want to search for a string in each file and copy only the matching lines to another location while preserving directory structure. ...
2
votes
6answers
79 views

Rename multiple files to decrement number in file name?

I have incorrectly named files which are unsynced by -1. The problem is I need to rename 1000s of them. DBGC180_805754 DBGC180_805755 DBGC180_805756 to DBGC180_805753 DBGC180_805754 ...
2
votes
4answers
114 views

How to convert all files from gzip to xz on the fly (and recursively)?

I have a directory tree with gzipped files like this: basedir/a/file.dat.gz basedir/b/file.dat.gz basedir/c/file.dat.gz etc. How can I convert all of these from gzip to xz with a single command and ...
2
votes
1answer
39 views

What is the difference between -H and -L options of chown?

From the chown manpage: The following options modify how a hierarchy is traversed when the -R option is also specified. If more than one is specified, only the final one takes effect. -H if a ...
1
vote
2answers
57 views

How to recursively side by side diff directories with line numbers in the diff in unix?

My scenario is to perform side by side diff directories using: diff -ry <folder1> <folder2> along with the line numbers in the diff output. By default line numbers are not displayed in ...
2
votes
2answers
165 views

Copying faster than cp?

I am currently copying a large number of directories and files recursively on the same disk using cp -r. Is there a way to do this more quickly? Would compressing the files first be better, or maybe ...
3
votes
1answer
59 views

Make `rsync --link-dest` find files recursively

I'm using Rsync as a backup tool. When I create a new backup, I would like it to look in all the existing backup folders for each file and if it already exists, create a hard link. From the Rsync man ...
-7
votes
1answer
62 views

Difference between changing permission Recursively or without Recursively

What is the difference in the command chmod 777 * and chmod -R 777 * changing permission recursively or normally?
0
votes
2answers
143 views

How can one recursively rename directories without sed or rename?

I am trying to rename a few directories that contain "Fever" to contain "Malaria" instead. The instruction is to do it without sed or rename. So far, my errors include mostly lines like mv: cannot ...
0
votes
2answers
49 views

explain recursion syntax

I'm new to shell, and UNIX / GNU/Linux. I'm trying to understand this syntax that is part of a recursion function: [ $i -le 2 ] && echo $i || { f=$(( i - 1)); f=$(factorial $f); f=$(( f * i ...
4
votes
5answers
1k views

How to recursively remove execute permissions from files without touching folders?

I made a backup to an NTFS drive, and well, this backup really proved necessary. However, the NTFS drive messed up permissions. I'd like to restore them to normal w/o manually fixing each and every ...
1
vote
1answer
78 views

wget not downloading files recursively

I saw some of the posts on this website about how to download files from a directory recursively. So, I executed the following line: wget -r -nH --cut-dirs=3 -A '*.bz2' -np http://www.xfce.org/...
2
votes
0answers
53 views

convert attachments of type winmail.dat (TNEF) to “real” attachments in stored email messages, recursively in MailDir

Some email messages contain the attachments in a format called TNEF (Transport_Neutral_Encapsulation_Format). This attachment is usually called winmail.dat. Extraction tools exist for linux, but ...
3
votes
1answer
539 views

Print recursively all directories and subdirectories

I am trying to print all directories and sub directories with a recursive function but I get only the first directory. Any help? counter(){ list=`ls $1` if [ -z "$(ls $1)" ] then ...
17
votes
9answers
5k views

Counting lines of code?

if I want to count the lines of code, the trivial thing is cat *.c *.h | wc -l But what if I have several subdirectories?
0
votes
1answer
24 views

“find” doesn't list all files under specific directories

I'm attempting to get a list of all files under specific folders, recursively, with the "find" command. find / -path "/usr/sbin/*" -o -path "/usr/bin/*" -o -path "/usr/local/sbin/*"-o -path "/usr/...
-4
votes
2answers
61 views

recursive script not working

I am trying to add recursive support to my filegrep script. For some reason this does not work as expected: RECURSIVE_MODE=off # iterate over args for ARG in "$@" do if [ -d "$ARG" ] && ...
1
vote
2answers
68 views

Rename all the files with a specific extension in all the subdirectory [duplicate]

I have a lot of directories. Each one of these has a file with a specific extension .ext. I want to rename these files. Example: // Note: The names are random, can have spaces and special ...
1
vote
1answer
67 views

Why is chmod recursively changing file permissions as well?

When I do chmod _+x -R /dir where "_" is any combination of (u,g,o,a), if after I do chmod g+X -R /dir, the files gain executable permissions as well. Why does this happen? This behavior only ...
0
votes
1answer
70 views

How could I quickly find a recursive symbolic link? [duplicate]

I am experiencing an issue with a indexing program running much longer than expected. I want to rule out the possibility of a recursive symbolic link. How could I find a symbolic link that is ...
1
vote
1answer
45 views

How to search recursively within several levels of embedded tar tgz files? [duplicate]

Can somebody help me to figure out a command to find a file recursively that is embedded in a tgz file which is within another tgz files recursively: MainFile.tgz → SubFile1.tgz → SubFile2.tgz → ...
2
votes
1answer
47 views

Will zgrep recursively search zips embedded within zips?

I am using the zutils version of zgrep v0.9 (not the gzip wrapper script) and to recursively grep zip files starting from the current folder I simply use: zgrep -r "MY_STRING" . This works fine. ...
0
votes
1answer
37 views

Bug in shell script for printing the tree-like structure of the curent diretcory

I have wrote the following script: #!/bin/bash if [ $# -eq 0 ] then read current_dir else current_dir=$1 fi function print_tree_representation () { for file in `ls -A $1` do ...
0
votes
0answers
99 views

how do I execute a command on multiple files located in different directories at once and directing the output to a new directory

I am trying to write a script that will execute a command on files in many directories while returning the output to another directory in an organised way. I did a dry run and got some good results ...
1
vote
2answers
250 views

Change Directory and execute command automatically then change directory back out

I'm attempting to write a script that will be run in a given directory with many single level sub directories. The script will cd into each of the sub directories, execute a command on the files in ...
0
votes
3answers
79 views

Grep in many directories, but only look in each dir's specific subdirectory, not all sub dirs

My case: dir1 subdir1 FooFile subdir2 dir2 subdir1 FooFile subdir2 So, if I cd dir1, I can easily do something like find . | xargs grep "Foo" in order to list the names of all ...
1
vote
1answer
178 views

How to find files and act on them (find + exec)

I have downloaded about 3200 websites to the depth 2. So now I have one master folder (abc) that contains many folders, containing files for each website. So my folder abc contains 3200 folders and ...
2
votes
2answers
82 views

How can strace monitor itself?

I have a Hypothetical Situation. (1) Let us say we have two strace Processes S1 & S2, which are simply monitoring each other. How can this be possible ? Well, in the command-line options for ...
4
votes
3answers
693 views

Copy only certain file types from a folder structure to another

I have a top folder with many sub-folders. It's named "a". There are many .png and .jpg files in there. I'd like to recursively copy "a" into a new folder "b", but only copy the .png and .jpg files. ...
1
vote
3answers
51 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
235 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: #!/bin/...
-3
votes
1answer
112 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
67 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. Unfortunately,...
6
votes
3answers
323 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
66 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
57 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
428 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
131 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
312 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
512 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. me@ice4:~/...
1
vote
1answer
335 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 ...