Operating on a directory and its subdirectories, recursively.

learn more… | top users | synonyms

3
votes
4answers
6k views

Move all files with a certain extension from multiple subdirectories into one directory

Suppose I have a bunch of zip files in several directories: Fol1/Fol2 Fol3 Fol4/Fol5 And I want to move them all to a common base folder. How would I do this?
2
votes
1answer
1k views

Makefile $wildcard only matches top directory

I am trying to implement a makefile for my C project which has a directory structure as follows: PROJECT_FOLDER: folder1 folder2 folder // n number of folders main.c FOLDER1: ...
3
votes
1answer
137 views

Passing all files of specific filetype in current and subdirectories

I have constructed an elaborate 500+ character command with many arguments and switches to autosign multiple PDF documents. I'm using JSignPDF and I'd like to use it's batch mode including the ...
4
votes
3answers
2k views

Manipulate file name piped from find command

I'm relatively new to Bash and am trying to do something that on the surface seemed pretty straightforward - run find over a directory hierarchy to get all of the *.wma files, pipe that output to a ...
1
vote
2answers
153 views

find “an expression” on each file of a directory recursively

One of my website on my webserver has suffered an attack : code injection. Here is the malicious code : <script type=\"text/javascript\" language=\"javascript\"> (function () { var t ...
0
votes
3answers
708 views

Sed find/delete for a string with multiple special characters recursively

I'm having quite a bit of difficulty with a complex string. A friend's site was hacked and has since been locked down but I'm helping to clean up the mess leftover and what I need to do is the ...
5
votes
3answers
4k views

wget - How to download recursively and only specific mime-types/extensions (i.e. text only)

How to download a full website, but ignoring all binary files. wget has this functionality using the -r flag but it downloads everything and some websites are just too much for a low-resources ...
11
votes
3answers
3k views

Flattening a nested directory

This is probably very simple, but I can't figure it out. I have a directory structure like this (dir2 is inside dir1): /dir1 /dir2 | --- file1 | --- file2 What is ...
3
votes
2answers
367 views

Fastest way to get list of all file sizes

I'm trying to create a graph of the distribution of file sizes on my ext4 system. I'm trying to write a script to scrape this information from my computer somehow. I don't care where the files are ...
1
vote
5answers
731 views

Run a command on all the files in a directory tree and put the output into a variable

I want to run this bash command : #!/bin/bash rep="*" for f in `ls -R`$rep; do d='git log '$f'| wc -l' c=$d echo $c done how to excute a command git log myFile | wc -l from bash ? ps : this ...
10
votes
2answers
3k views

Recursive glob?

I'd like to write something like this: $ ls **.py in order to get all .py filenames, recursively walking a directory hierarchy. Even if there are .py files to find, the shell (bash) gives this ...
2
votes
1answer
2k views

How can I queue up an entire directory for FTP?

Currently I know how to do this: curl -T file.zip ftp://server.domain.com/ --user username:password Which will let me do a single file. However I can't figure out how to do it for a directory. I ...
4
votes
3answers
657 views

How can I list all *.doc files in a Zip archive, including files in subdirectories?

I have Zip files, that might look like this: $ zipinfo -1 zip.zip doc.doc dotx.dotx xls.xls ppt.ppt txt.txt c.c subdir/subdir2/doc.doc subdir/xls.xls subdir/ppt.ppt subdir/c.c subdir/txt.txt ...
4
votes
3answers
642 views

id3v2 used recursively at command line?

Trying to get my id3 tags cleaned up and am loving id3v2 on the command line -- but I've been using it only with a *.mp3 wildcard and want to explore if there's a way to use it recursively so I can ...
4
votes
2answers
4k views

How can I search a wild card name in all subfolders?

How can I search a wild card name in all subfolders? What would be the equivalent of DOS command: dir *pattern* /s in *nix?
8
votes
2answers
8k views

Locate and delete all temporary files in user directory

I use vim a lot, and my area has power failure a lot. So the resultant is I get many *.swp files scattered over my PC. I want an alias of rm command that removes all files with either .swp, ~, ...
5
votes
1answer
1k views

Search for a string in files recursively in BusyBox 1.0? [duplicate]

Possible Duplicate: How to grep a text recursively on BusyBox 1.0? How can I search for a string in a file recursively in BusyBox 1.0 if find and grep are not available ? (I want to telnet ...
4
votes
2answers
4k views

Difference between cp -r and cp -a

Looking for the difference between cp -r and cp -a? What does recursive mean in terms of copying files from a folder?
0
votes
1answer
268 views

PHP file recursive change array key on find [closed]

I used PHP array $lang['module']['1'] = 'Title'; $lang['module']['2'] = 'Title2'; $lang['value'] = 'text123'; how i can use replace in terminal Key Value to CASE UPPER ? $lang['VALUE'] ...
5
votes
2answers
3k views

Where does grep -r search by default?

I found if I search using grep without specifying a path, like grep -r 'mytext' it takes infinitely long. Meanwhile if I search with path specified grep -r 'mytext' . it instantly finds what I need. ...
1
vote
3answers
166 views

line count on all the PHP scripts within my webroot with wc

How can I do a line count on all the PHP scripts within my webroot? I am trying something like this below to no avail: wc -l *.php
2
votes
2answers
578 views

Search for file permisions other than 755

In AIX really, how can I search in several directories and those below it, for files that are not of the specific permissions of 755. So I want to search /path/to/, /path/to/mydir, ...
0
votes
2answers
3k views

How to search all subdirectories and their subdirectories for the occurence of a word using grep? [duplicate]

Possible Duplicate: Searching for string in files Suppose I have a directory called Home and it is my current directory. And in this home directory I have many other directories ...
4
votes
1answer
149 views

What is the tool that allows me to specify arbitrary directories using **

I once saw a colleague uses a tool which allows to use ** to represent any directories. For example: if a file called myfile.java sits deep inside: src/main/com/mycompany/product/store/myfile.java ...
7
votes
4answers
2k views

Find files with same name but different content?

I want to generate a list of files that have: Same name Different content in a directory (including all children directories and content). How to do? Bash, perl, anything is fine. So, two ...
2
votes
1answer
2k views

How do I create a local copy of a complete website section from OSX using wget?

This question follows from: How do I create a local copy of a complete website section from OSX using curl? After discovering OSX's native curl wouldn't do this task I downloaded wget from here: ...
1
vote
1answer
582 views

How do I create a local copy of a complete website section from OSX using curl?

I'm trying to download Mathematics of the Discrete Fourier Transform so that I can read through it off-line on my iPad (which doesn't have an Internet connection) I have used wget in Linux. It seems ...
1
vote
1answer
2k views

How to grep a text recursively on BusyBox 1.0?

How can I find a file containing a certain string on a BusyBox 1.0, if grep -r does not work?
7
votes
1answer
183 views

Strange behaviour in recursive copy

Could someone explain why this happens? Most specifically: Why is one 1's content copied to f? And why is f copied to g? $ tree . 0 directories, 0 files $ mkdir 1 $ mkdir 2 $ touch 1/a $ touch ...
14
votes
3answers
5k views

How to list files that were changed in a certain range of time?

How can I list recursively all files that were changed between 22.12.2011 and 24.12.2011?
1
vote
3answers
1k views

routing wget --recursive to stdout (as in -O -) rather than a file

I want to "scan" a website content, recursively, and pipe it to another program. When I run: wget -r -O - $SITE I get WARNING: combining -O with -r or -p will mean that all downloaded content ...
7
votes
4answers
14k views

Using sftp to Transfer a Directory?

When I try to use sftp to transfer a directory containing files, I get an error message: skipping non-regular file directory_name The directory contains a couple of files and two subdirectories. ...
6
votes
3answers
7k views

How can I find all files that do NOT contain a text string?

What concise command can I use to find all files that do NOT contain a text string? I tried this (using -v to invert grep's parameters) with no luck: find . -exec grep -v -l shared.php {} \; ...
4
votes
6answers
6k views

Recursive search doesn't work for grep on solaris

On our Solaris server I'm finding that grep -r doesn't work, which is the usual way that I use grep. It seems that egrep has the same behavior. Given that I have no control over the machine, is there ...
3
votes
3answers
227 views

Track daily directory changes (and email them)

I have a Debian powered NAS server (ReadyNAS) with a deep file hierarchy. I'd like to get notified daily about what has changed in some of its directories and their subdirectories. So if someone ...
3
votes
2answers
6k views

Search string in many files on HP-UX

I need to find which files (they can have space in the filename) of a directory contains a string using only sh and system's commands (Perl is not an option). For a few files, this command works ...
7
votes
2answers
5k views

How do I stop a find from descending into found directories?

I'm wanting to find all directories with a specific string so I can do another find on the files contained within. So I don't want to waste time on ./my-search-term/dir/my-search-term etc. How can I ...
2
votes
3answers
2k views

create md5 hash from a recursive file listing when some paths have spaces

I need to create an md5 hash of every directory and file inside of one main directory. The only thing that is keeping me from success is figuring out a way around files with a space in the path. I am ...
9
votes
4answers
14k views

How do I recursively delete directories with wildcard?

I am working through SSH on a WD My Book World Edition. Basically I would like to start at a particular directory level, and recursively remove all sub-directories matching .Apple* - how would I go ...
4
votes
2answers
9k views

How can I move a directory onto an existing directory?

I need to essentially merge changes on two trees, applying the changes from branch 2 to branch 1. I have trees like this: media ├── cd │   ├── 0 │   │   ├── file1 │   │   ├── file2 │   │   └── file3 ...
3
votes
2answers
931 views

recursive 'ls' giving absolute filenames

When I do 'ls -R' in a directory, I get something like ./dir1 dir2 file1.txt file2.txt ./dir1/dir2 file3.txt file4.txt but I would like a command that gives me ./dir1/file1.txt ./dir1/file2.txt ...
5
votes
3answers
2k views

recursively copy only images and preserve path

I'm working on a website migration. I have a scrape of the site, with all the files and directory structure as you would see them in the URL. I want to pull all images, maintaining the directory ...
22
votes
3answers
20k views

How to search text throughout entire file system?

Assuming that the grep tool should be used, I'd like to search for the text string "800x600" throughout the entire file system. I tried: grep -r 800x600 / but it doesn't work. What I believe my ...
3
votes
4answers
3k views

Find file by a part of its content

I have many files in a specific repository and i must find a file which has a specific string in its content (actually referencing the file Version.cc.in). What is the best solution to find it?
3
votes
2answers
287 views

Searching for string in files

Is there an easy way to search inside 1000s of files in a complex directory structure to find files which contain a specific string within the file?
1
vote
0answers
398 views

Move files to specific directories [closed]

This question is the same as http://askubuntu.com/questions/47155/reorder-files-inside-folder: I have about 30K songs in mp3. I already organized/tagged them with Musicbrainz Picard. But Picard made ...
5
votes
4answers
4k views

Find a string only in a specific file inside subdirectories

Let's say I need to find the function GetTypes() in all C# source file (.cs) the directories/subdirectories. I used grep -rn GetTypes *.cs, but I got an error with grep: *.cs: No such file or ...
5
votes
4answers
2k views

find not recursive when file at top

Imagine a source tree. There are xml files everywhere. But since there is a XYZ.xml at the root of this tree it won't find my xml files. find -iname *.xml returns ./XYZ.xml instead of ...
3
votes
2answers
848 views

Find files with same name but different extensions, send to tgz

I have a large archive of edited images from my camera, each image is actually a pair of files - *.nef & *.xmp. I would like to go through all the folders and then zip these pairs into single tgz ...
8
votes
6answers
26k views

How to remove all the files in a directory?

I am trying to remove all files and subdirectories in a directory. I used rm -r to remove all files, but I want to remove all files and subdirectories, excluding the top directory itself. For ...