Using Ubuntu. I have a directory, with some sub directories, which may have some files with names formatted like this: So, they all start with ‘core’. then a process name, then the PID number, which is usually 4 or 5 digits. My Python based tool uses two ‘find’ commands to find them, l…
Tag: find
Linux/shell – Remove all (sub)subfolders from a directory except one
I’ve inherited a structure like the below, a result of years of spaghetti code… In reality, this folder is thousands of subfolders large. I only need to keep ./gallery/{number}/full/* (i.e. the full folder and all files within, from each numbered directory within gallery), with everything else no …
find and remove all closed files that are not modified in some-time
I’m building a script in linux that will remove files from the disc that aren’t in used currently by the OS. I want to use find command so I can execute rm for all the files that I find that are not open. I tried so far this command without success: I found this command in some website it supposed
Change file names by Perl [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 7 years ago. Improve this question How t…
bash script – executing find command gives no output
I’m a total noob at bash so this is most likely a syntax error, but I could not find anything that worked for my syntax in my searches. From terminal, running find . -name “*g*” results in However, running this bash script called grepdir.sh from terminal as grepdir.sh . “*g*” res…
How to find newest files with a certain name?
Suppose I have a directory with many files of the same name in subdirectories (for example, comes up when keeping BibTeX files for multiple academic papers). What’s the best way to find the newest version of a file with a given name? I’ve come up with the following command which lists all the file…
I’ve found a way to use find -exec to cp multiple files all in one line like xargs, but I’m not sure exactly how it works
I’ve been working with find -exec and find | xargs for the past few hours exploring and experimenting, and now I’ve found a variation of the command that I haven’t seen anywhere else. For example this find command to get all files in the child subdirectories and copy them to the current dire…
crontab not working under arch linux
I tried to set up a schedule to remove the old file and folder after several days. I put the following code in a script file and tried to use crontab to run it every day. The find command worked fine. but the crontab seems not execute the script file. I also use crontab for other tasks, i.e. rsync, they
How do I ‘skip’ minified JavaScript files while searching through a tree of js files?
I search a large js tree frequently for certain Tokens. Consider you were looking for all of the ‘.prototype’ tokens in your js files. I would do something like this: Of coarse this produces a boat-load of hits on minified vendor libs. Obscuring the real results I am after. i.e: results like that …
How to display modified date time with ‘find’ command?
With a find command, I can display directories names with multiple levels. The following command display all directories under /var path with a depth of 2: The result shows: With a stat command, I can find the modified date time: The result is: Is there a way to combine the two commands so that directories wi…