1
vote
2answers
54 views

How to determine the newly closed file within a continuous audit log rotation?

I am attempting to find the best way to determine when the second file (of a matching criteria) is created. The context is an audit log rotation. Given a directory where audit logs are created every ...
3
votes
1answer
120 views

find files without extension

Let say I have: foo.txt bar baz.ooo If I use ls -1 !(*.*) then I'll get only bar on the output. Great, now I wish to have same results with find - some find -regex that will do the job. NOTE: ...
2
votes
2answers
63 views

Remove files and directories even if not empty, except some directories

I am trying to remove all contents of a directory with some exclusions. I'm currently using this: find . -type f | grep -vZf ../../exclude.file | xargs rm -rf The exclude.file contains: *log* ...
1
vote
2answers
68 views

Using exec in find over ssh from shell script

So, I am attempting to execute the following from within a shell script; ssh -q $CUR_HOST "cd $LOGS_DIR; echo cd $LOGS_DIR; find . -name *.log -mmin +1440 -exec gzip {} \; exit" When this runs, it ...
0
votes
2answers
39 views

Output multiple strings out of multiple files

Hi my current code is: find /home/user/logfilesError/ -maxdepth 1 -type f -name "gBatch_*"\ -daystart -mtime -1 -exec grep -rl "ERROR" "{}" + | xargs -l basename if [ $? -eq 0 ]; then ...
0
votes
1answer
46 views

How to output the lines of a file after find and a grep?

Hello I want to output ERROR messages from logfiles from the current date. First I search for the logs of today with specific prefix: find /home/USER/logfilesError/ -maxdepth 1 -type f -name "xy_*" ...
0
votes
2answers
36 views

How can I search filenames which are starting with xy_* and are created/edited today?

Hello I´m currently trying to search for logfiles which are starting with xy_Number and are created/edited today(not last 24 hrs). I tried: find /home/USER/logfilesError/ -maxdepth 1 -type f ...
0
votes
1answer
31 views

better use of find - rvm.sh

I am trying to find rvm.sh as I am receiving the infamous rvm is not a function error. The file in most linuxes is supposed to be at /etc/profile.d/rvm.sh However on opensuse it is not there so I ...
3
votes
3answers
409 views

'is a directory' error when trying to pass directory name into function

Note: I am a newbie to bash scripting In my bash script, I use find to get the folder names by wildcard: for i in $(find ${directory} -mindepth 1 -type d -name ${wildcard}); do stuff=doStuff ${i} ...
2
votes
2answers
144 views

find the single largest file

We host a share of size 4 TB. How efficient is it to find a file with highest size. Usually we use: du -ak | sort -k1 -bn | tail -1 and it is not easy to scan through a share of such huge size and ...
0
votes
2answers
45 views

find action not working for specific search [duplicate]

I'm trying to use the find command to list the size of a certain set of files but am getting no output. The command I use is: find POD -type f -name *.mp3 -or -name *.ogg -ls Which produces no ...
1
vote
2answers
94 views

find command throws errors when inside function

I can run the following command in bash without any errors: $ find /d/Code/Web/Development/Source/ \( -name '*.cs' -o -name '*.cshtml' \) -exec grep -IH UserProfileModel {} \; I wrote a function in ...
0
votes
1answer
65 views

Trying to pass user generated variable to an external command

I have a bash script that is asking a user for input, then passes that variable to a find command. I've tried quoting/escaping the variable every way I know, but it keeps failing. read -p "Please ...
2
votes
3answers
154 views

Count result in a find/exec statement

I have some Perl files which I have to modify through a simple sed call. Basically, I have to remove the first line of all of them. Currently, I managed to do this : find <PATH> -type f -name ...
2
votes
2answers
197 views

Symlink all subdirectories in a directory to another directory

I'm trying to symlink every directory in a folder to another folder. For example, in the structure below, I need the subfolders symlinked to folder2. - /home/chris/folder1 -- subfolder1 -- subfolder2 ...
12
votes
3answers
523 views

Two find commands comparison

Recently I received this find one-liner, but I'm not able to explain where the difference of the below two comes from: Example 1 [root@centos share]# find . -exec grep -i "madis" {} /dev/null \; ...
3
votes
2answers
71 views

How to find Emacs backup files?

Emacs backup files start with .# but I can find those in my directory. I've try: find . -name '^\.#.*' or find . -name '.*#.*' and they are not show up, and I have them. For instance if I create ...
0
votes
2answers
108 views

Handling files with whitespace in their names

I have a lot of files that I need to sift through, specifically grep for certain keywords IN THE FILE, not he FILENAME. I have some 300+ files on a filesystem (so the files are within multiple ...
1
vote
1answer
585 views

Basename gives extra operand error

I 'm using the following script to merge few pcap files into one using mergecap command. But when I run it it gives me a 'basename: extra operand /mnt/md0/capture/DCN/dcn_2014_02_04_00_11_47_598.pcap' ...
0
votes
2answers
111 views

Deleting large number of files

I'm writing a script to delete large number of files in linux. The script will run every two minutes in crontab. I tried using the find /mnt/md0/capture/DCN/ -maxdepth 1 -type f -name "*.pcap" ...
4
votes
2answers
208 views

Find files newer than another file within each subdirectory

I have a folder structure like this /Class/Student/Unit/files Each Unit folder contains a file MarkSheet* that I update when I mark a students work. I need a script that tests if the student has ...
2
votes
4answers
193 views

Using a generated list of filenames as argument list — with spaces

I'm trying to invoke a script with a list of filenames collected by find. Nothing special, just someting like this: $ myscript `find . -name something.txt` The problem is that some of the pathnames ...
1
vote
1answer
42 views

find: prune does not ignore specified path

I need to exclude .git from my find search. To achive that, I am using the -path ./.git -prune switch: $ find . -path ./.git -prune -o \( -type f -o -type l -o -type d \) | grep '.git' ./.git ...
9
votes
3answers
2k views

identify files with non-ASCII or non-printable characters in file name

In a directory size 80GB with approx 700,000 files, there are some file names with non-English characters in the file name. Other than trawling through the file list laboriously is there: An easy ...
1
vote
2answers
81 views

visit all directories under version control

Is there a find incantation that would allow me to visit all directories under SVN version control? I am trying to use the execdir switch to add to the svn:ignore property in each one of these ...
3
votes
3answers
382 views

find with execdir

I run a find with execdir both I don't get the results I was expecting. SSCCE below: mkdir -p a/b/c find . -type d -execdir touch foo \; $ tree a a ├── b │   ├── c │   └── foo └── foo Directory c ...
0
votes
2answers
275 views

Tail multiple files and output as additional column with 'find' results

Would like to pull the last line of text from a specific (multiple) files in a directory. Additionally, I'd like the results to be in a more traditional column format (like ls) with path, rather than ...
0
votes
3answers
103 views

apply specific command for each git repository

I want compress all the git repositories on my computer (say in ~). I.e., for each directory {}, that contains directory or file (in case of submodules) named .git, I want to execute git gc ...
2
votes
3answers
62 views

using regex with find

Let's say I need to find all files in /var/log/ except btmp, lastlog, wtmp. And I only need depth 1. I tried with the following find command, but that does not work as expected: find /var/log/ ...
1
vote
2answers
69 views

double-quoting parameter (representing filename) doesn't help if spaces are contained

When iterating over some filenames double-quoting the parameter does not prevent the filename from being broken: $ mkdir temp $ cd temp/ $ touch a\ b $ for f in $(find .) ; do echo "$f" ; done . ./a ...
4
votes
6answers
962 views

ls with find :: report total size

I am trying to get the total size of files satisfying a find, e.g.: ls $(find -maxdepth 2 -type f) However, this kind of invocation of ls does not produce the total size as well.
4
votes
4answers
1k views

What is the most efficient way to move a large number of files that reside in a single directory?

CentOS 5.x I apologize if this is a repeat question. I've seen a lot of similar questions (regarding deleting files) but not exactly the same scenario. I have a directory containing hundreds of ...
2
votes
3answers
214 views

how to pipe find's output into another find

In searching how to make find sort the files it finds based on modification time I found this answer which provides the following incantation: find . -type f -printf '%T@ %p\n' | sort -k 1nr | sed ...
2
votes
1answer
99 views

Check for existence of files prior to acting on them

In one of my processes I check for existence of files older than 31 days, and then do stuff with them. find /my/directory/*txt -mtime +31 -exec ls -l {} \; All this is well and fine if files are ...
1
vote
2answers
322 views

Need to copy files to existing directory and remove files already there with the same name but different extension

EDIT: Total rewrite of question for clarity. I have a directory tree (new) with a bunch of files of with an extension of .new. I have an identical tree (old) where many of the files have names ...
3
votes
2answers
148 views

find: combining -path and -prune to exclude files and directories

I have a directory /srv/tftp/pxelinux.cfg and a file /etc/mtab. I want to exclude both from find. But whatever I do, either one always is not excluded find /etc /srv -path /srv/tftp/pxelinux.cfg ...
4
votes
3answers
125 views

What is the difference between [.]* and '.*' for command 'find -name'?

My goal is to find all files or directories in a filesystem that start with a dot (.), for example .gnupg. So I came up with the command: find -name '.*' Checking on the Internet, I saw some hints ...
3
votes
2answers
2k views

find files not matching list of filename patterns

I find myself needing to find and identify extraneous files (out of about 900K files on a 2T drive). There are lots of files that I want to keep, and I have filename patterns for these known good ...
4
votes
2answers
2k views

recursive search for a pattern, then for each match print out the specific SEQUENCE: line number, file name, and no file contents

What I am after is almost exactly the same as can be found here, but I want the format "line number, separator, filename, newline" in the results, thus displaying the line number at the beginning of ...
1
vote
2answers
285 views

How to find certain files and move them to a new directory in the same command?

So I was looking around and all I have found is how to do this only if the directory is already made, which is this: find source -name '*.z' -exec cp {} destination \; But how can I make a new ...
2
votes
5answers
346 views

Delete all files in directories except those whose path are listed in a file

Given the following files: data/A/a.txt data/B/b.pdf ... date/P/whatever.log ... data/Z/z.jpg I would like to delete all files in the data/A/, data/B/, ..., data/Z/ directories except those files ...
5
votes
5answers
18k views

Why does find -mtime +1 only return files older than 2 days?

CentOS 5.9 I'm struggling to wrap my mind around why the find interprets file modification times the way it does. Specifically, I don't understand why the -mtime +1 doesn't show files less than 48 ...
2
votes
4answers
416 views

Zgrep stop after first match when arguments are passed from xargs

I'm using this command to find patterns in zip files (similar to the one) suggested here http://superuser.com/questions/144926/unix-grep-for-a-string-within-all-gzip-files-in-all-subdirectories find ...
3
votes
1answer
306 views

find multiple conditions with multiple execs

I'm trying to build a find command with multiple conditions that lead to multiple actions. It was suggested to me that I should use only one find command for efficiency. Here is what I have: ...
2
votes
4answers
668 views

Scope of variables when calling function from find

In a bash script I define a function that is called from find. The problem is that the scope of variables does not extend to the function. How do I access variables from the function? Here is an ...
2
votes
2answers
99 views

Filtering the result of the find command, so that it returns only directories

Is it possible to get only the results from find that are directory paths? Using find with some option, or using grep or some other utility the results are piped into as a filter? I thought something ...
3
votes
1answer
514 views

find and rysnc?

I want to be able to search for files over 14 days and over 10k and than rsync those found files to a destination. Is there a way to combine these two commands? find ./ -mtime +14 -size +10k rsync ...
3
votes
1answer
214 views

Why does this one-liner clobber files?

I have written this to help me batch-encode some videos: find -name '*.mkv' -exec HandBrakeCLI -Z "Android Tablet" \ -c "1-3" -m -O --x264-tune film -E copy --decomb -s 1 -i {} \ -o `echo {} | tr ...
2
votes
2answers
1k views

Get list of all files by mask in terminal

I want to find all *.h,*.cpp files in folders with defined mask, like */trunk/src*. So, I can find separately *.h and *.cpp files: find . -path "*/trunk/src/*.h" find . -path "*/trunk/src/*.cpp" ...
3
votes
1answer
144 views

Variable declaration in parallel sh -c …

I've been trying to process the output of find with parallel, which in turn invoked a shell (some textual substitutions were needed). I observed some strange behaviour, which I cannot really explain ...