recursive

How to get gzip operating recursively at all depths?

How to get gzip operating recursively at all depths? I mean to gzip all files *.vtu, at all depths below a given directory, in bash. I have such files at depths 1 and 2 below ./. I managed to do so with $ gzip -v $(find . -name "*.vtu") I could also use find … …

Total answers: 3

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

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: homeappsBatcheshello.txt homeappsBatchestesttext.txt Output: homeappsBatches homeappsBatchestest Only the files should be deleted. Asked By: amalAF || …

Total answers: 1

How to replace all matched strings in the files recursively?

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"} http://localhost:4542/wp-content/uploads/2022/09/ src="http://localhost:4542/wp-content/uploads/2022/09/B http://localhost:4542/wp-content/uploads/2022/09/A replies":[{"embeddable":true,"href":"http://localhost:4542/en/wp-json Any tool/ commands to replace http://localhost:4542 to https:example.com recursively in all files of a folder? Working on a …

Total answers: 3

Detect leaf directories in Perl

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 their own. For example, given this hierarchy: foo/ foo/bar/ foo/bar/baz foo/you_fool my hypothetical function, when called …

Total answers: 3

BASH recursive rename of js files to jsx

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 understand script to do …

Total answers: 1

How to provide grep a file with ip addresses to look for in access.log

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 Now I want to scan access.log …

Total answers: 2

Recursively list path of files only

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 other. My thinking is I will make a list of all the …

Total answers: 3

How to recursively delete the contents of all "node_modules" directories (or any dir), starting from current directory, leaving an empty folder?

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 projects/ I want to delete the contents of all node_modules/ directories, but I …

Total answers: 1

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

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 files have pretty common names like robots.txt and don’t follow any …

Total answers: 2

Wget: downloading files selectively and recursively?

Wget: downloading files selectively and recursively? Question about wget, subfolder, and index.html. Let’s say I am inside “travels/” folder and this is in “website.com”: “website.com/travels/”. Folder “travels/” contains a lot of files and other (sub)folders: “website.com/travels/list.doc” , “website.com/travels/cover.png” , “website.com/travels/[1990] America/” , “website.com/travels/[1994] Japan/”, and so on… How can I download solely all “.mov” and …

Total answers: 1

How to chmod only on subdirectories?

How to chmod only on subdirectories? Given the following directory tree: . ├── d1 │   └── workspace ├── d2 │   └── workspace ├── d3 │   └── workspace ├── d4 │   └── workspace └── d5 └── workspace I need to set the permissions for all workspace directories as below: chmod -R 774 d1/workspace chmod -R 774 …

Total answers: 4

Accidentally created symbolic link to a folder in that folder

Accidentally created symbolic link to a folder in that folder I was creating a symbolic link to folder1/folder2 in home-folder. But I accidentally did: ln -s folder1/folder2 while in folder2 instead of in home-folder. So I ended up accidentally creating a sort-of-recursive link. Now I can’t remove this link: rm folder1/folder2 gives the error message …

Total answers: 2

cp behaves weirdly when . (dot) or .. (dot dot) are the source directory

cp behaves weirdly when . (dot) or .. (dot dot) are the source directory This answer reveals that one can copy all files – including hidden ones – from directory src into directory dest like so: mkdir dest cp -r src/. dest There is no explanation in the answer or its comments as to why …

Total answers: 2

Using Perl rename to rename files and directories

Using Perl rename to rename files and directories I’m using the Perl rename command line tool to search recursively through a directory to rename any directories as well as files it finds. The issue I’m running into is the rename command will rename a sub-directory of a file then attempt to rename the parent directory …

Total answers: 2

filter in "find" ignored when output fed to tar

filter in "find" ignored when output fed to tar I have the following directory structure: test/ test/1/ test/foo2bar/ test/3/ I want to compress directory “test” excluding everything which is in subdirectories (depth not predefined), which include strings “1” or “2” in them. In bash shell, i want to use find and feed its output to …

Total answers: 2

Parallelize recursive deletion with find

Parallelize recursive deletion with find I want to recursively delete all files that end with .in. This is taking a long time, and I have many cores available, so I would like to parallelize this process. From this thread, it looks like it’s possible to use xargs or make to parallelize find. Is this application …

Total answers: 2