Operating on a directory and its subdirectories, recursively.
2
votes
1answer
29 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
280 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
139 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
34 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
105 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
18 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
74 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
92 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
28 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
157 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
749 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
26 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
354 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
84 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
366 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
285 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
669 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
366 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
363 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
220 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
166 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 ...
4
votes
2answers
525 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
1k 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
73 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
417 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
404 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
651 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
1k 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
596 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
186 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
687 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
123 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
1k 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
50 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
354 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
490 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
376 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 ...
2
votes
4answers
2k 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
156 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
155 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
816 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, ...
0
votes
3answers
704 views
Find executable files recursively
I have got the directory called Test and a few directories inside it. Both Test and the directories inside it have executable files. I'd like to print them with ls. I'd use this command.
ls -l `find ...
4
votes
4answers
1k views
How to recursively find the amount stored in directory?
I know you are able to see the byte size of a file when you do a long listing with ll or ls -l. But I want to know how much storage is in a directory including the files within that directory and the ...
3
votes
4answers
5k 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
854 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
128 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 ...
2
votes
3answers
1k 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
143 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
614 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 ...