Operating on a directory and its subdirectories, recursively.

learn more… | top users | synonyms

9
votes
2answers
955 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
30 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
36 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
42 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 ...
1
vote
3answers
30 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
158 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
73 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
68 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
64 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
385 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
329 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
42 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
190 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
26 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
103 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
145 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
30 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
207 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 ...
4
votes
3answers
1k 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
27 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
507 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
88 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
699 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
415 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
991 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
448 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
807 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
311 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
193 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
695 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
84 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
744 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
519 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
723 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 ...
2
votes
2answers
855 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 ...
1
vote
1answer
224 views

I quite like mercurial .hgignore-style globbing. Is there a Linux shell that supports it?

I quite like mercurial .hgignore-style pattern globbing. Globs are rooted at the current directory; a glob such as *.c will only match files in the current directory ending with .c. The ...
5
votes
4answers
890 views

chmod recursive permission on thousands of files

This is a more general question about 'chmoding' recursively. I have this script which at some point needs to change the permissions recursively in a folder which has a few hundred thousand files. ...
4
votes
4answers
131 views

How to deal with spaces in a variable

I'm working on some scripting: for x in `find ./ -name *.pdf` do echo pathname $x done My filenames are Test1 ( Volume II), Test2 ( Volume II). I'm getting a return of pathname Test1 pathname ( ...
2
votes
2answers
2k views

How can I rename all files with one extension to a different extension recursively [duplicate]

Say I have a folder: / /a.bub /v.bub /dr.bub /catpictures /catpictures/or.bub /catpictures/on.bub How can I format a script to change each of these to .aaa. Here is what I've got, although it ...
1
vote
1answer
53 views

Change some ASP code to PHP code in all files

I'm migrating a directory of files containing fairly simple ASP code over to a PHP server and I need to modify the contents of all the files with a find and replace mechanism. I'm not great with ...
2
votes
3answers
415 views

Help searching in files for regex patterns, recursively, with specialized output

My problem is that I need to: Find all lines matching regex_pattern in all files (deep search) in a given root directory For each line that matches, output: File name Line number containing the ...
5
votes
2answers
1k views

Excluding a specific directory using a recursive 'ls'

I've been using the following command to list the most recently updated files (recursively) within a specific directory and order by modification time: $ stat --printf="%y %n\n" $(ls -tr $(find * ...
1
vote
3answers
625 views

How to rename pattern in one file to another over several directories recursively

I have several directories through which I want to recursively iterate over and change the file name of *.GEOT14246.* to *.GEOT15000.* Is there a one liner on the bash script to do this ...
1
vote
1answer
429 views

wget recursive with files without extension

I'm not very good with Linux so I have maybe a basic question. I've search around for the "how to" and I couldn't find anything. I'm trying to get a site with wget. The problem is that it: Have ...
3
votes
5answers
3k views

Find and copy directories containing file type

I have a directory "Movies" containing subdirectories "Movie Name". Each subdirectory "Movie Name" contains a movie file and related image/nfo files etc. I'm trying to copy all directories containing ...
1
vote
2answers
202 views

Search and replace full line in recursive files

I'm using: grep -n -H -o -R -e textword . List all file recursively under directory '.' with string 'textword' and show the file, line and only portion matching. I need to remove lines that ...
1
vote
2answers
168 views

Direct recursive shell script output to each subdirectory, not parent directory

I'm processing a batch of subjects data recursively, calling the script within the parent directory. For example, I have the parent directory: /home/subjects and the subdirectories which contain ...
2
votes
2answers
989 views

Excluding a directory name in a zsh recursive glob

I'm running zsh on Linux under setopt extended_glob ksh_glob glob_dots. I'm looking for something easy to type on the command line, with no portability requirements. I'm looking at a source code tree, ...