Questions tagged [find]

For questions pertaining to find, a command-line utility to search for files in a directory hierarchy. Use this tag for questions about find itself or questions about issues arising from using the find command-line utility.

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

Find tar archives not already existing as folders

I have a couple of tar archives, among them, some have the same filename as folders: folderA folderA.tar folderB.tar ... I want to be able to list/find all the tar files (ideally on the same/current ...
0
votes
1answer
10 views

Make Tar update existing archives only if present

So i have this one-liner i used: find . -maxdepth 1 -mindepth 1 -type d -exec tar cvf {}.tar {} --remove-files \; Where it tar each top directory into their own tar archive, while deleting files ...
0
votes
1answer
27 views

find suspect behaviour

I am looking, in the current directory, for all files writable by owner and/or group but not writable by all: find . -type f -perm /220 ! -perm /002 -exec ls -l {} \; | tr -d '\.\/' | sort -k 9 -u -...
0
votes
1answer
10 views

It it posssible to skip found files within found folders when using find?

I am looking for a command that only outputs the following two folders and skips found files within found folders. /Users/sunknudsen/Library/Application Scripts/com.brothersroloff.SyncBuddy /Users/...
0
votes
3answers
30 views

separate outputs of “find” with a space in terminal

I am using find to find all folders which include more than 20 of a specific type (.txt) as below: find . -type f -iname '*.txt' -printf '%h\n'|sort|uniq -c | awk '$1 > 20' The output looks like: ...
2
votes
4answers
57 views

how many command invocations with find -exec command {} +

find manpage states: -exec command {} + This variant of the -exec action runs the specified command on the selected files, but the command line is built by appending each ...
-1
votes
1answer
31 views

Deleting all subfolders except one recursively

I would like to create a one-liner, that would delete subfolders recursively, preserving the newest directory per subfolder. This probably can be achieved by chaining some find and rm commands, but I ...
1
vote
1answer
23 views

Search for a string in all searched files gives /bin/grep: Argument list too long error

I tried the below command to search for in all files user /var sudo find . -type f | xargs sudo grep 202007602 | tee /tmp/202007602.log Output: grep: ./www/html/jenkins/workspace/node_modules/xpath/...
1
vote
2answers
52 views

Searching multiple files for a string, without regular expressions?

Is there a command that can search multiple files for a string, where that command (perhaps modified by a certain option) doesn't support regular expressions? I'd like this for the speed of avoiding ...
3
votes
2answers
144 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
1answer
47 views

How to run second command only when first is successful when using find and xargs?

My situation is: I have many files with a name timestep1_i for many values of i and I am trying to combine all the files for timestep1 with a program called combinefiles. I want to do it in parallel (...
0
votes
0answers
35 views

Get the last modified file's epoch time in current directory

I need to get the epoch time which belongs last modified file in current directory. I have some limitations: must be compatible with RHEL and AIX systems AIX does not allow -printf option with find ...
5
votes
3answers
386 views

Reliable way to open files given by the result of find … -exec grep … {} \+

I often run commands like this: find … -exec grep … --color=always -l {} \+ and sometimes I need to open the matching files in Vim. But what is the most reliable way to do so? One way seems to be vim ...
1
vote
2answers
39 views

Find command in linux and delete, but test with print, give no results

I'm trying to find some files on my NAS and then delete the files/folders that's more then 5 days old. I can use the find command as: find /volume1/docker/UV/videos -type f -print And then i get all ...
3
votes
3answers
199 views

-perm flag in find

I'm trying to wrap my head around this command: find /home/ -type d \( -perm -0002 -a ! -perm -1000 \) 2>/dev/null I understand that it's going to look in the 'home' directory for all directories ...
0
votes
1answer
52 views

How to find a file and make that the current working directory (cd)

I am trying to make an executable script on Mac where it searches for a file and makes that the current directory (cd) and then runs some more commands. I started with find . -type d -name "...
1
vote
2answers
38 views

Aliasing grep in find's -exec option

I have these aliases in my ~/.bashrc alias grep='grep --color=auto -H' alias fgrep='fgrep --color=auto -H' alias egrep='egrep --color=auto -H' but they have no effect when I run find ... -exec grep .....
0
votes
1answer
32 views

Delete directories after compressing with tar

I´m trying to compress a whole directory tree, leaving just one .tar.bz2 file instead of each directory that I found with find. The purpose is to create a cronjob for doing this in weekly basis. The ...
0
votes
1answer
44 views

Linux find command - find files based on inode and device?

I want to find the files with a given inode number. Using find with -inum is not entirely helpfull as its listing files with the inode number from every file system/device. How to confine this search ...
0
votes
1answer
40 views

How to find evey softlink to a directory?

Take /etc dir as example. On my system it has 144 links. And as dir's can't have hardlinks (this is my understanding), the number 144 should refer to softlinks (1 original + 143 softlinks). $ ll -i ...
7
votes
2answers
2k views

How to effectively trace hardlink in Linux?

Softlinks are easily traceable to the original file with readlink etc... but I am having a hard time tracing hardlinks to the original file. $ ll -i /usr/bin/bash /bin/bash 1310813 -rwxr-xr-x 1 ...
-1
votes
1answer
44 views

Find files modified in last hour that contain certain word

I want to find files modified in the last hour which contain a certain number. I currently have the following: find . -maxdepth 1 -mtime -0.5 | grep -lir "100" This is returning all files ...
-1
votes
1answer
65 views

dpkg-query: no path found matching pattern /usr/bin/bash

What does it mean when package manager can not determine from which package the corresponding command was installed. When I do - $ sudo dpkg -S /usr/bin/passwd passwd: /usr/bin/passwd from the ...
1
vote
1answer
36 views

Linux find command - how to find directories by size?

Can find return results based on the size of directories? Below command is working fine as expected - find * -type f -size +10M -exec ls -hlSr {} \+ But on applying the same to directories its not ...
3
votes
4answers
232 views

Reversing file name change made with find command?

Find is a great utility - and it's versatile. I trying to rename files by adding suffix or prefixes to existing file names. Cool. find -name "*" -exec mv {} {}.yo \; Now here's the though ...
0
votes
1answer
31 views

Delete all zip files from a folder recursivley

I am trying to delete all zip files from a folder /mnt/drive1/temp and its subfolders recursivley. I am aware that an incorrect command here could have disastrous consequences so wanted to check I had ...
0
votes
1answer
27 views

Find with exec causing repeated output?

What is causing the output of ls to be printed twice? $find . -exec ls -l {} \; total 340 -rw-rw-r-- 1 w w 163244 Aug 26 19:25 apt-list--installed.txt -rw-rw-r-- 1 w w 162078 Aug 26 19:25 apt-list.txt ...
0
votes
1answer
43 views

Print only files, directories containing files and empty directories

I am trying to index some LTO tapes (and some hard disks as well) and would like a simple output, stored in a text file. Something like the example below: ... /home/norg/Desktop/empty\ dir/ /home/norg/...
-1
votes
1answer
34 views

Why does “find” only print directories it is searching when there are no test flags?

When I issue something like sudo find . "*dev/null" to bash, the shell prints out the directories that match the expression as well as every single directory that it searches through to ...
0
votes
0answers
16 views

Find a file in XDG directories

Today I was looking for all the mimeapps.list files in my system. Essentially one should test the following files: $XDG_CONFIG_HOME/mimeapps.list $XDG_CONFIG_DIRS/mimeapps.list $XDG_DATA_DIRS/...
2
votes
2answers
128 views

-exec to xargs conversion in find command

I'm using the below command in my script to perform a dos2unix operation on the files which I copy from Windows to Linux. There are many files, so it takes a considerable amount of time to perform ...
-1
votes
3answers
27 views

How do I exclude any results with permission denied when using the find command? [duplicate]

So I am trying to find any file containing the name IDLE. This is the command I used: find / -xdev -name "IDLE.*" -type f -ls > IDLE_find.txt The output in the console just gives me a ...
3
votes
1answer
51 views

Renaming files with non-ASCII files to append their own datetime in ASCII

Multilingual environment and our file storage on linux of course allows all those international (Asian) characters in filenames. But this is causing problems syncing to other systems because the ...
-1
votes
2answers
61 views

How would I use the find command to display files containing a word?

I want to use the find command and only output the files in the console with their path that the find command actually found. Cause if I now use the command it will also display all the files it ...
0
votes
0answers
35 views

Using the find utility within a simple function in .bashrc does not work. Why? [duplicate]

I'm using the latest arch kernel 5.7.12-arch1-1, the latest bash version 5.0.017-1 and the latest coreutils-8.32-1 which the find utility is a part of. I have the following code in my .bashrc to make ...
0
votes
1answer
31 views

How to extract a compressed tar using cpio to a particular directory location

I created the compressed tar file using the below command. find /app/jboss -not -name "*.err" -not -name "*.log" | cpio -o | gzip >/app/patchbkp/test/REDHAT_jboss-eap-7.2_18-Aug-...
0
votes
2answers
40 views

Count the number of directories in a list of directories

I have a large number of directories, and I want to count with bash commands the number of directories in each of these directories. I am having a hard time piping ls and wc to achieve what I want. E....
1
vote
1answer
23 views

Trying to recursively move files to a combined folder, need to rename same-named files, backup method not working

I have a large directory 'Pictures' that has a lot of individual sub directories, each with varying number of image files in them. I want to move every file that is in sub directories into a single, ...
2
votes
1answer
31 views

Rename all files with specific format which are in folder with specific name

In my project I have a lot of test files, which are named *.ts. They are all in __tests__ folders, but it can be __tests__/test1.ts, __tests__/dir2/test2.ts and so on. I would like to rename those ...
5
votes
5answers
1k views

Most efficient way of changing 1 line in a file

I want to change the first line of hundreds of files recursively in the most efficient way possible. An example of what I want to do is to change #!/bin/bash to #!/bin/sh, so I came up with this ...
0
votes
0answers
37 views

Bash: remove spaces in directory name [duplicate]

!! This question is not about SHELL, it's about BASH, can't change the faulty tag !! I've got a code that removes the spaces in directories and filenames (and inserts a dot); find $jdir -depth -name &...
-1
votes
2answers
33 views

move files up a level preppending folder-name to file-name?

Test environment: make directories from 0 to 9 and fill them with files from a to z $ mkdir {0..9} && touch {0..9}/{a..z} Result of find: $ find -type f ./0/a ./0/b ... ./9/y ./9/z How ...
1
vote
0answers
79 views

Show files modified after a particular date ('find') in hierarchical format ('tree')

I'm trying to view files modified before or after a certain date using the hierarchical output of the Unix tree command. For example, I know that one can use tree to sort files chronologically and ...
-1
votes
1answer
61 views

GNU grep & find -regex: Why is . needed in the regex and why can't i use POSIX character classes?

I was trying to find files in a certain directory which don't adhere to the naming guidelines for UNIX-like systems. When using with find the command find <dir> -regex '.*[^-_./0-9a-zA-Z].*' ...
-2
votes
1answer
30 views

How to automaticaly remove folders and its content, which are more than 20 days old?

I have a parent folder raw_response_csvfiles which contains multiple folders named a,b,c...z. a,b,c...z folders contain lot of csv files. How do I automatically remove the folders a,b,c..z and the csv ...
0
votes
1answer
39 views

Omitting/filtering dirs from find output

find /home/alex/devops/backups/ -maxdepth 1 -type d -mtime +60 Outputs : /home/alex/devops/backups/ /home/alex/devops/backups/R8.1 /home/alex/devops/backups/R11.0 /home/alex/devops/backups/R.16.2.1 ...
3
votes
1answer
35 views

Can the Linux find -iname option take more the one pattern

Using the Linux find command -iname option, I want to find and move files that have many different extensions (.pdf, .doc, .xlx, .ppt). I know I can use multiple patterns with grep. But can that ...
0
votes
3answers
53 views

how to use find command on top of the output of ls

I have below command which displays files/directories having EXEC_EC command: ls -ltr | grep 'EXEC_EC' By using above command: Can we write a find command to filter the files created before 7 days? I ...
0
votes
0answers
54 views

Ambiguous output redirect error in find command [duplicate]

Apologies if this is a repeated question, I am trying to search for a file in all the subdirectories in a given path. While doing so I also want to suppress any output messages, errors from the find ...
-1
votes
2answers
53 views

How do I get the required input for this 'for' loop?

I've written a small script made to backup downloads from TOR because occasionally TOR will try to merge its place holder file (a zero byte file with original file name) and its actual download file (...

1
2 3 4 5
58