Questions tagged [recursive]
Operating on a directory and its subdirectories, recursively.
340
questions
0
votes
1
answer
45
views
how to find all pics in a directory and its subdirectories and run a command on them
how to find all images in a directory and its sub-directories, with types gif, jpg, jpeg, png, ico, and run mogrify -strip your_filename.jpg on them?
Can the command mogrify -strip corrupt an image?
...
2
votes
1
answer
66
views
Recursively perform an operation on all files in a directory and its subdirectories
Based on this answer, I want to perform an operation on all the files in a directory and its subdirectories.
The following command works a single file, and also works when used on multiple files in a ...
0
votes
3
answers
363
views
How to replace all matched strings in the files recursively?
There are about 50 HTML/js files in the folder name site,
some of the files contain (below lines are combined from files)
{"rendered":"http:\/\/localhost:4542\/?page_id=854"}
...
1
vote
3
answers
78
views
Detect leaf directories in Perl
For a Perl script I'm working on, I'm looking for a fast and reliable way to find all subdirectories (transitively) of a given directory which are leaves, i.e. those not having any subdirectories of ...
0
votes
1
answer
24
views
How to get file list + permission statistics + analyze for uncommon permissions + finally batch change certain permissions to other permissions?
I copied some legacy files/folders from /srv/my-old-disk/_oldstuff/ to /srv/my-normal-disk/_oldstuff.
How do I get this analysis for /srv/my-old-disk/_oldstuff/ ?
How do I then change certain file ...
2
votes
1
answer
729
views
BASH recursive rename of js files to jsx
On a mac I'm migrating a create react app to vite and have a lot of *.js files that need changing to *.jsx. I done this manually once in my life and this is enough for one eternity.
I need a simple to ...
2
votes
2
answers
546
views
How to provide grep a file with ip addresses to look for in access.log
Situation
I have a file where each line has an IP address and I want to see if these Ip's are found in access.log
File name: IpAddressess
Contents example :
192.168.0.1
192.168.0.2
192.168.1.5
etc etc
...
1
vote
3
answers
249
views
Recursively list path of files only
Why
I have two folders that should contain the exact same files, however, when I look at the number of files, they are different. I would like to know which files/folders are present in one, not the ...
1
vote
1
answer
130
views
How to recursively delete the contents of all "node_modules" directories (or any dir), starting from current directory, leaving an empty folder?
Suppose I have a directory structure like this:
projects/
project1/
src/
node_modules/
dir1/
dir2/
dir3/
file
project2/
node_modules/
dir4/
Starting from ...
0
votes
0
answers
73
views
"find" command gets killed when trying to work on thousands of files
I am trying to create PBF out of thousands of OSC changeset files using osmium tool. I have written a Bash script for doing this task using Jenkins.
I am merging all OSC files into one master OSC ...
0
votes
1
answer
87
views
Do grep and cp treat "recursive" the same?
I'm having trouble with grep's manner of interpreting "recursive" searching compared to cp. Maybe it's just that I use them differently.
In this, grep seems to interpret "recursive"...
0
votes
3
answers
544
views
Curl against list domains from a file not working
I have a bash script below that is intended to curl against a list of domains, from a file, and output the results.
#!/bin/bash
baseurl=https://csp.infoblox.com
domains=/home/user/Documents/...
3
votes
1
answer
492
views
Handle names with spaces when iterating recursively over files [duplicate]
I am trying to recursively convert all .mkv files in a folder structure with subfolders to .mp4.
I got a standard line that works in just the present folder
for video in *.mkv; do ffmpeg -i "$...
0
votes
2
answers
1k
views
How to zip specific individual files in a directory
for example, this folder ~/folder1/folder2 contains a lot of files like:
abc_0101.txt abc_0102.txt ...
abc_0201.txt abc_0202.txt ...
abc_0301.txt abc_0302.txt ...
abc_0401.txt abc_0402.txt ...
how to ...
0
votes
1
answer
120
views
For all zips, and unzip in working directory and maintains its structure
With this command
find . -name '*.zip' -exec unzip '{}' ';'
we find all zip files under . (directory), then unzip them into the current working directory,
However, the structure is gone.
/backUp/...
0
votes
0
answers
202
views
Run script recursively
I have a script that will concat and rename the video files in a folder which I have pieced together using tips from StackExchange.
#!/bin/bash
ls -d $PWD/* >> file.txt
sed -i "s/^\|$/'/g&...
0
votes
1
answer
98
views
Rsync: Clone structure for specific pattern [duplicate]
How can one recursively copy all files of a specific pattern (*.tpl) using rsync?
Example:
/etc/test.tpl
/etc/dir/test.tpl
/etc/dir/**/test.tpl
1
vote
1
answer
2k
views
find all file extension recursively from directory and copy all extension files to single directory [duplicate]
I have directory with sub-dir where it has multiple extensions file. I would like to copy all ext files to single directory "scan". Tried running following cmd but doesnt work out:
find . -...
0
votes
0
answers
22
views
Confusion Regarding Slowness Of Recursive Find
This command takes greater than 2 minutes to return:
find . -type d -wholename ./dev-abcd/efgh
It makes me think there's many subdirectories. I checked that with the below command, which returned ...
0
votes
0
answers
84
views
Combining recursive find, numbered backup, & copy for multiple files with the same name in subdirectories and subdirectories of those subdirectories
r.xml are the files, and s is output directory. What I want is the s directory to contain r1.xml, r2.xml, etc..
$ ls -R
s temp temp3
./s:
./temp: r.xml temp2
./temp/temp2: r.xml
./temp3: r....
1
vote
4
answers
1k
views
Apply same sed command on multiple text files
I am doing some pre-processing on files. I have 2 text files which contains data in the following format.
Text File 1
"Name","Age","Class"
"Total Students:",&...
1
vote
1
answer
68
views
Can I define an alias in bashrc in an incremental way?
In my .bashrc, at the moment, I have something like this:
if [ -x /usr/bin/dircolors ]; then
# ...
alias ls='ls --color=auto -F'
# ...
fi
# xxx
alias ll='ls -AltF'
Now let's say that I ...
6
votes
2
answers
1k
views
How do I recursively run "chgrp" without changing the group if it matches a specific group?
I just copied all the files/subdirectories in my home directory to another user's home directory.
Then I did a recursive chown on his home directory, so that he became the owner of all his files/...
0
votes
3
answers
378
views
"grep -rn" only yields one of two expected results
I am trying to find all the files in a directory structure which contain a specific word, but it is not working correctly.
For example: when run from the path /Institute/IITDhanbad/, the command
grep ...
0
votes
0
answers
65
views
Why doesn't ls -d -R $PWD/* | grep searchforthistext work, but combinations of its components do?
I tried going to / and using ls -d -R $PWD/* | grep searchforthistext to find any directories or files in my computer with searchforthistext, and give me their absolute path (since simply using ls -R |...
1
vote
1
answer
121
views
How to parallelize a recursive bash function?
I have a bash function that mainly curls an endpoint for a set of links, and again curls each of those links (for another set of links) recursively.
task() {
link="$1"
response=$(curl &...
4
votes
2
answers
868
views
Sort and remove duplicates in place and recursively
I would like to sort all files in all subdirectories in place. I have 65536 files in 256 directories, every file containing one word a line, and each file contains duplicates.
What I would like is to ...
1
vote
1
answer
297
views
Rename hundreds of filenames to replace or delete specific words including duplicated words via MacOS Terminal (bash/sh/zsh?)
Summary
I have thousands of pictures that were titled in full sentences. I am trying to automate a way to do clean them up with a single script, and then reuse that script as I add more pictures.
The ...
0
votes
3
answers
225
views
Recursively traverse directories and retrieve last timestamp file
Let's suppose I have the following timestamp like directory tree:
root
|__ parent1
| |__ 2021
| | |__ 01
| | | |__ 22
| | | | |__ 12H
| | |...
0
votes
0
answers
32
views
Figure out changed directories in nested structure
I have a script that needs to parse a directory tree that is around 5 levels deep and sync it into an external service. To minimize the amount of work (there will be a lot of directories on each level)...
0
votes
0
answers
66
views
Why does wget create "_Conflict" directories?
I am trying to back up a club website to a NAS. Here is a simplified version of the script I am using which illustrates what is happening (without going too deep or accessing protected content):
cd /...
0
votes
2
answers
793
views
How do I handle file names with spaces when changing permissions for certain files in the current directory and all its subdirectories?
I am currently trying to set all files with extensions .html in the current directory and all its subdirectories to be readable, writeable, and executable by their owner and only readable (not ...
3
votes
1
answer
317
views
zsh find -execdir rename "no such file or directory"
I'm trying to write a zsh script on MacOS Big Sur that will recursively rename some files and directories that have special characters I don't want. Been at it for days and every time I think I have ...
0
votes
2
answers
415
views
List all files in subdirectories sort by subdirectory name
I have a folder that has many subfolders in it. I want to list all the files in all the subfolders but I want the files sorted by subfolder name. I'm not interested in files in the current directory.
...
0
votes
2
answers
455
views
Find directory matching a specific name and recursively copy from the parent-dir of find search-results
I have a directory structure like this: m/n/o/p/q/r/s/t.
I want to find directories that match by name "r" and copy contents recursively from the parent-dir of the find-result (ie. "q/r/...
0
votes
1
answer
175
views
Make API requests recursively without large number of processes running
I have the following Script File 'bored.sh'. This file recursively calls itself.
curl "https://www.boredapi.com/api/activity" >>./bored.json
sleep 1s
bash ./bored.sh
I realized that ...
-2
votes
1
answer
36
views
How to recursively list subdirectories and their sizes?
I have a directory with many subdirs and many files inside those. All I need is to figure out how much space each subdir takes. So I need something like ls -lR in that I want to see the entire ...
0
votes
1
answer
75
views
Perform loop in HPC within multiple subdirectories one after another
I know this is a repeated question, but none of the suggestions I saw kinda fit what I wanted.
I'm working with an HPC cluster that has different modules to perform different actions for high ...
0
votes
1
answer
173
views
Use parallel to speed up a recursive shell max function?
I needed a max function, to find the highest value in an array (of 350 int values), and being a friend of recursion, I tried a recursive approach:
max () {
len=$#
a=$1
b=$2
case $len ...
0
votes
1
answer
188
views
Recursively downloading websites with frames
I have not been able to recursively download some pages on a website that uses links within frames, and further links in those frames. It is from zhongwen.com, an online chinese etymology dictionary.
...
0
votes
0
answers
655
views
How to recursively download a whole directory in one run via FTP
I am trying to migrate a folder from one server to another, using FTP on Linux via SSH. I am not finding a command to download all the masses at once. The Commands that I found only download the files ...
0
votes
2
answers
1k
views
Is it possible to delete contents of a directory mounted inside itself?
Just for curiosity, is it possible to delete contents in a directory which is mounted inside of itself OR in a folder inside it?
For example, I was taking a backup of my Arch installation with ...
3
votes
2
answers
323
views
How might one except hidden '.' files and directories from a script that renames them?
I have a script that renames, getting rid off the whitespace, every directory and file. It does it recursively:
#!/bin/bash
find -name "* *" -print0 | sort -rz | \
while read -d $'\0' f; ...
1
vote
4
answers
535
views
rm -rf with missing w permissions on directories without root or chmod
I'm trying to recursively delete a directory with rm -rf, but this fails because some inner directories don't have the w permission set. I know how to fix this with chmod. However, this requires to ...
3
votes
1
answer
1k
views
delete wildcard throughout subdirectories, Mac OS
I would like to delete wildcard throughout all subdirectories under the directory where I run the command.
2
votes
1
answer
238
views
Prepend user-defined string to all files and folders recursively using find and rename
Prepend user-defined string to all files and folders recursively using find and rename.
I’d like to prepend “x “ (no quotes) to a directory and all of its contents down through all subdirectories. I’m ...
0
votes
1
answer
676
views
How do I recursively tar+gzip folders with a specific name?
I have a large file structure with multiple nested folders. I would like to tar+gzip up every folder with a specific name and remove the original folder.
In this example the script I hope to have ...
-1
votes
1
answer
41
views
Unix script that will recursively look for specific names [closed]
Trying to find a Unix script that will recursively look for directories/files that contain in their name " backup ", "back" etc. or more than 6 numbers, so it can find those that have a date. Thank ...
0
votes
1
answer
62
views
Output file blows up when trying to find strings on bash on ubuntu on windows
I'm using Bash on Ubuntu on Windows to run linux commands on my windows system. It seems to work just like Ubuntu so for all intents and purposes I'm on ubuntu here I guess.
I'm trying to use strings ...
0
votes
2
answers
176
views
How to execute recursively a program on every files contained in directory with find
I wrote an executable that I want to execute on all the files contained in a directory.
This is what the program looks like:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types....