Questions tagged [recursive]

Operating on a directory and its subdirectories, recursively.

Filter by
Sorted by
Tagged with
-1
votes
0answers
26 views

How can I recursively check an entire file system for IP addresses?

I've found How to check if any IP address is present in a file using shell scripting? but I don't know how to apply that to the entire file system.
0
votes
0answers
26 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
2answers
66 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
2answers
151 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; ...
0
votes
0answers
8 views

Is pax required to stop when a file already exists in the destination directory and the k option has been given?

The POSIX manpage says only that -k shall "prevent overwriting of existing files". That doesn't tell me if all the other files will be copied, or only the ones before the existing one, or ...
1
vote
4answers
84 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 ...
1
vote
1answer
38 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
1answer
59 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
1answer
52 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 ...
0
votes
0answers
51 views

Using scp with excluding files recursive - also problems in .sh-script

I want to sync via scp from my testserver to an website ssh-server. On my testserver I try out my webpage, and then copy it online. On the simple php-website I am using .htaccess files for password ...
-1
votes
1answer
37 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
1answer
29 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
2answers
29 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....
2
votes
3answers
271 views

Recursively replace with RegEx w/ grep & sed while maintaining capture groups?

What a long title. Essentially, what I have is a collection of files that need to be searched recursively with a regex, and replaced. What I have so far works without capture groups, however it does ...
0
votes
2answers
28 views

Grepping across multiple directories

I want to run this: grep -r zlib *.cpp But this fails unless there is a .cpp file in the current directory (in which case only it is searched): grep: *.cpp: No such file or directory Now: grep -...
1
vote
0answers
18 views

do a recursive file compare for newness and report

I have Ubuntu 16.04 and have been using Dropbox over the years and found it solid in reliability. Recently started using Zoho docs and like it, but I find its syncing flaky. I would like to continue ...
0
votes
0answers
138 views

Is it possible to convert all video files in subdirectories on google drive using ffmpeg & rclone?

Currently I'm using this code whereby rclone fetches 1 file from my google drive, converts it using ffpmeg on a server and moves the converted files to the same folder. It's shown as below. Step 1 is ...
0
votes
1answer
77 views

Updatedb on samba mounted shares

I have a few directories mounted from a samba share server (my lan storage) and I would like to run updatedb on them. I use to successfully run such command to do that: updatedb -l 0 -o ~/.myDbFile....
0
votes
2answers
550 views

Unix how to copy file to directory and echo

I am trying to write a script using a for loop to copy files to a directory that will also echo the copy command to the terminal. I have successfully gotten the script to copy files, however, am ...
1
vote
1answer
64 views

Append file name to beginning of [Markdown] file recursively

I have a folder with a whole lot of folders with a whole lot of Markdown files in each. What I'd like to do is recursively (if possible) prepend the file name as a heading in each file. So, given foo....
1
vote
1answer
48 views

Recursive thumbnail creation to different destination

I wish to show my photo collection on my television. In order to do this, I need to resize the photos to fit in a 1920x1080px window (because the performance is awful when dealing with the originals). ...
0
votes
1answer
465 views

Flattening directory and renaming files incrementally (MacOS)

Looking to flatten the directory (with duplicate child file names) while renaming all files, keeping duplicates OR appending all file names with an incrementing number (incrementing # + name would be ...
0
votes
1answer
125 views

How may I emulate the -R feature of “zip”, but in gzip and xz?

The program "zip" has a -R feature which allows one to zip all files with a certain name in a directory tree: zip -r v/s zip -R For example: zip -R bigfile "bigfile" Will zip all of the following: ...
3
votes
5answers
400 views

Moving all files with same file extension .txt to a new directory

Basically, my hard drive is a mess and I have like 200+ sub-directories in a main directory. I want to essentially move all files in 200+ sub-directories that have the extension .txt etc to a new ...
0
votes
2answers
31 views

Command to recursively delete all files with changing extension number

I know how to delete recursively all files with a specific extension, but how about if that extension has a number appended to it? For example, how can I delete files named .d3plot1, .d3plot2, ....
1
vote
2answers
879 views

how to unzip a zipped file which include various zip level files in unix/linux? [duplicate]

For example my folder name is Test.zip Test.zip includes various zip folders like te1.zip, te2.zip , te3.zip even te1.zip include various zip folders. So i need to unzip in linux at once. Could ...
0
votes
3answers
82 views

Sort output of find command, read back in to remove files

The following bash script searches through all directories and tabulates how many files are in each directory. Sample output testing on my own R installation is below - exactly what I need. find . -...
0
votes
1answer
41 views

Recurse massive dir structure, delete files over X days

First linux coding job. Told to make a script for a chron job that dives through all folders on server and deletes any files over X days (probably 20). I have tested the code below on my home ...
1
vote
2answers
83 views

Wrong result when recursively count lines with wc

I am using the following Linux command to recursively count lines of text files in a folders structure: find . -name '*.txt' | xargs -d '\n' wc -l This outputs all found files and their number of ...
0
votes
1answer
82 views

How to recursively find file, concatenate into one file and simultaneously delete the original file

As I understand it, I could use find . -name '*.txt' -exec cat {} \; > all.txt to concatenate all the text files in a directory, recursively throughout sub-directories, into a file called all....
0
votes
2answers
967 views

How do I make this rsync command non-recursive?

rsync -avi --delete --modify-window=1 --no-perms --no-o --no-g ~/Documents/Stuff/ /media/user/PC/Stuff;; i.e. to not copy sub-directories from the source directory?
2
votes
1answer
1k views

Grep contents recursively, print only 1 directory level deep

I want to search within file contents, recursively on subdirectories, but I only care about whether the first level subdirectory contains any matches. That is, given: ParentDirectory ...
0
votes
2answers
55 views

Copy folders to another set of directories, only if folders already exist

I want to copy (overwrite) folders from one directory to another set of directories, only if the folders in directory1 exist in directory2. For example, I have stored some folders in my home ...
-2
votes
2answers
883 views

cp -a doesn't work to copy all files inside a directory

I desire to copy all files inside a directory which has only these files (all are regular files - there are no directories, symlinks, etc, inside that directory) to another pre-existing directory. The ...
1
vote
2answers
149 views

Recursively flattening subdirectories in a root directory and maintaining level 1 sub-directory structure

I have a large n-level directory structured as follows: root | subdir1 | sub_subdir1 | ....(n-2 levels)..... | ...
0
votes
1answer
160 views

How do I write a shell script to flatten directories?

I wrote a simple script to delete useless files from a directory using the find command. Now I'm wondering if I can add lines to the script to flatten directories, but not completely flattened. e.g.,...
2
votes
2answers
626 views

Sort and mv files based on filename (with spaces), recursively

I have made a mistake and dumped files together into the same directory. Luckily I can sort them based on the filename: ''' 2019-02-19 20.18.58.ndpi_2_2688_2240.jpg ''' Where the # bit or 2 in this ...
1
vote
2answers
175 views

Bash recursive call fails

I am writing a function in ./bashrc to switch environment variables, commands, etc. This function is supposed to set up the necessary variables then call itself. Instead I get bash: ./bash: No such ...
-6
votes
1answer
433 views

What is the meaning of -r and -R in copy command?

I read that they stand for recursively in the man page. However, I am not sure what their role is in the command. When I tried to copy some empty directory into another directory with, $ cp EMPDIR ...
0
votes
2answers
35 views

Recursively copying a folder to an empty subfolder

How to copy all the content of the folder /foo/bar, which contains the file /foo/bar/a to an empty subfolder /foo/bar/subfolder without ending up with the file /foo/bar/subfolder/subfolder/a. Doing cp ...
0
votes
1answer
57 views

Move Files Recursively but only if they are not open by another process

I want to modify the script text below, to change the file permissions, owner and move it, only if the file is not open by another process. cd /mnt/usbdrive/DVR sudo chown 777 -R /mnt/usbdrive sudo ...
1
vote
1answer
1k views

Recursively converting Windows files to Unix files

I have a PHP application with is located on Linux with multiple directories (and sub-directories) and many PHP, JS, HTML, CSS, etc files. Many of the files have Windows EOL control characters and I ...
0
votes
2answers
383 views

Recursive conversion of jpeg files

I use this commandline to convert jpegs to pdfs inside a folder. for f in *.jpg; do echo "Converting $f"; convert "$f" "$(basename "$f" .jpg).pdf"; done However, I would like to convert all .jpg ...
0
votes
0answers
177 views

How to run command recursively on files within directory and sub-directories within? [duplicate]

How can I run the command below recursively on all directories and sub-directories within? [someone@someones-pc ~]$ for i in *.mp4; do ffmpeg -i "$i" -i watermark.png -filter_complex "overlay=1623:25"...
1
vote
1answer
1k views

Use SCP from local machine to recursively copy current working directory to remote?

Trying to do something like (in pseudo-unix): scp -r <pwd> username@remote.com:~/<dirname of toplevel> In other words, I'm trying to copy the current directory I'm in locally (and the ...
3
votes
1answer
208 views

Command “tree” vs “tree -R”

So I'm asking myself why there is the "-R" argument for the "tree" command. The manual says "-R Recursively cross down the tree each level directories ...", but I don't see any difference in the ...
1
vote
2answers
1k views

How to recursively copy a directory using cpio?

How do I copy recursively a directory within the list at my-files-to-copy.txt? cd my/source/dir cpio --create < my-files-to-copy.txt | (cd my/dest/dir && cpio --extract) my-files-to-copy....
2
votes
1answer
654 views

How to use istat on AIX like stat on Linux distributions

In Linux, I use the following command to show this output: find /backup/$INSTANCE/tsm/* -exec echo '"{}" ' \; | xargs stat --printf "chown %U:%G '%n'\nchmod %a '%n'\n" >> /tmp/permissions.txt ...
1
vote
1answer
879 views

How to search for a folder or file in parent folders [duplicate]

I tried to search for a folder in its parent folders instead of its child sub-folders (usually any search bash command will do). I need to know whether any reverse alternative for any search commands ...
-1
votes
4answers
190 views

Recursively rename all the files without changing their extensions?

How to recursively rename all the files in several layers of subdirectories without changing their extensions? Below's a toned down version (to save room) of what I've got. For argument's sake, I ...

1
2 3 4 5
7