Questions tagged [recursive]

Operating on a directory and its subdirectories, recursively.

Filter by
Sorted by
Tagged with
0 votes
1 answer
371 views

Delete all the files in a folder and its subfolders without deleting the folder structure

I am replicating a server -> I want to delete all the files inside the folders and the subfolders, without deleting the directories themselves. Example: home\apps\Batches\hello.txt home\...
amalAF's user avatar
  • 3
0 votes
1 answer
278 views

Recursively fix corrupted video files with ffmpeg

I think I'm pretty close to having a code which will start at a directory, then spit out a fixed copy, using fd (instead of find) and ffmpeg. I have written the if statement here as psudo-code: for i ...
1toneboy's user avatar
  • 425
0 votes
1 answer
67 views

Can find reliably call itself from -exec without breaking the semantics of the two instances?

Following http://superuser.com/questions/1780479 and http://superuser.com/questions/1777606, we issue the following script to compare times of the same–full-path symlinks under directories $1 and $2: #...
user avatar
0 votes
1 answer
281 views

how do you get the total size of wget recursive without downloading all the files first?

i have something large to download recursively the size is estimated to be > 150GB (someone told me this is roughly the size) right now i do not have the storage space so i need to figure out how ...
Trevor Boyd Smith's user avatar
1 vote
1 answer
137 views

How can I rename files recursively using a regular expression

I have hundreds of files on a hard drive with many directories and sub directories which start with: 1.1, 1.2, 1.3, 2.1, 3.1, 9.1, 10.1, 10.2, Etc Etc... The problem is that when I list them they ...
Chris Fox's user avatar
0 votes
0 answers
47 views

bash: enter every folder, search for filetype. If missing. download that file

new bash-beginner here. As a start into scripting I want to write a simple bash-script, which enters every folder within a specific path, check for filetype and if it is missing, do a certain wget-...
Thomas's user avatar
  • 1
0 votes
0 answers
67 views

Why does removing a directory first remove its subdirectories recursively?

Why must deleting dir1, which contains dir2, which in turn contains dir3, be a "recursive" operation and not just "simple" (destroying dir1 as-is, regardless of its contents)?
hamza's user avatar
  • 1
0 votes
1 answer
1k 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? ...
stacking and exchanging woohoo's user avatar
3 votes
1 answer
833 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 ...
jian's user avatar
  • 567
0 votes
3 answers
1k 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"} ...
Maxfield's user avatar
  • 161
1 vote
3 answers
141 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 ...
q.undertow's user avatar
0 votes
1 answer
183 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 ...
porg's user avatar
  • 574
3 votes
1 answer
3k 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 ...
SuperUberDuper's user avatar
2 votes
2 answers
1k 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 ...
user3077601's user avatar
1 vote
3 answers
868 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 ...
Olaf's user avatar
  • 113
2 votes
1 answer
1k 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 ...
Lawrence's user avatar
  • 329
0 votes
0 answers
102 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 ...
deewreck's user avatar
0 votes
1 answer
167 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"...
Jesse's user avatar
  • 345
0 votes
3 answers
1k 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/...
Nina G's user avatar
  • 777
3 votes
1 answer
1k 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 "$...
Dr_Bunsen's user avatar
  • 135
0 votes
2 answers
5k 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 ...
dcdum2018's user avatar
0 votes
1 answer
342 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/...
Maxfield's user avatar
  • 161
0 votes
0 answers
291 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&...
AKDub's user avatar
  • 11
0 votes
1 answer
154 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
Veles's user avatar
  • 135
1 vote
1 answer
3k 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 . -...
Ankur's user avatar
  • 11
0 votes
0 answers
51 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 ...
Howard_Roark's user avatar
1 vote
4 answers
2k 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:",&...
Mr. Underscore's user avatar
1 vote
1 answer
89 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 ...
Enlico's user avatar
  • 1,525
6 votes
2 answers
2k 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/...
pacoverflow's user avatar
0 votes
3 answers
685 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 ...
Suresh's user avatar
  • 111
0 votes
0 answers
154 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 |...
Joseph D.'s user avatar
1 vote
1 answer
193 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 &...
Zeta.Investigator's user avatar
4 votes
2 answers
2k 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 ...
James's user avatar
  • 71
1 vote
1 answer
673 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 ...
Billie Hawkins's user avatar
0 votes
3 answers
364 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 | | |...
Dani's user avatar
  • 103
0 votes
0 answers
36 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)...
Djent's user avatar
  • 101
0 votes
0 answers
84 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 /...
R B's user avatar
  • 126
1 vote
2 answers
1k 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 and writeable, and executable by their owner and only readable (not ...
Arata Kaizaki's user avatar
3 votes
1 answer
405 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 ...
J. Matthew Turmer's user avatar
0 votes
2 answers
861 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. ...
julesverne's user avatar
0 votes
2 answers
775 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/...
Optimized Coder's user avatar
0 votes
1 answer
324 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 ...
hillsonghimire's user avatar
-2 votes
1 answer
241 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 ...
I Z's user avatar
  • 99
0 votes
1 answer
125 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 ...
Sebastian Quezada's user avatar
0 votes
1 answer
255 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 ...
user unknown's user avatar
  • 10.5k
0 votes
1 answer
295 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. ...
Luke Sharkey's user avatar
1 vote
0 answers
2k 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 ...
Fabio Henrique's user avatar
0 votes
2 answers
2k 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 ...
Abhidesh128's user avatar
3 votes
2 answers
397 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; ...
John Smith's user avatar
2 votes
4 answers
1k 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 ...
Koen G.'s user avatar
  • 143

1
2 3 4 5
7