search for files in a directory hierarchy

learn more… | top users | synonyms

1
vote
1answer
30 views

Finding strings in files with relative path

I don't understand why this two commands don't provide the same result (the differrence is only relative vs. absolute path), can somebody explain it? annika /srv/www/pages/com.example.www/www/povruc ...
0
votes
1answer
21 views

cygwin find -ls behaviour like ls [on hold]

I use cygwin find with -ls (find . -ls) option to have a list of files with full path. Due to UTF-16 (windows XP in this case) converted to en_UTF-8 under cygwin, special charactere like accent are ...
1
vote
1answer
25 views

Why is find not excluding old files?

I want to copy all gzipped files from my apache logs that were created less than 43 days ago. As a test, I simply listed my files from find: sudo find /var/log/apache2/ -mindepth 1 -ctime -43 -name ...
2
votes
2answers
76 views

Running “find” command generates high load

I run this command on a Debian server with SSD drives configured as RAID 1: ionice -c 3 find . -type f -amin -1440 -mmin +1441 -not -path custom/ -print0 on a path which contains over 1.7M files and ...
3
votes
2answers
74 views

Why is my find -type d performing fstat on every file in a folder?

I'm running find . -type d on a rather large directory tree. I am only interested in finding directories within this tree, but when I ran an strace against the process to make sure it was doing what I ...
0
votes
2answers
38 views

Using find to exclude a directory and tar up everything else in a directory

I have following in a directory: dir1 dir2 file1 file2 I want to tar up everything except dir1 When I do: find . -path '*dir1*' -prune -o -print I don't see dir1 in the output ( as expected) ...
3
votes
1answer
38 views

List directories not containing a file which has a variable prefix

I'm checking the output from a script. In some cases the script has failed, and a certain file hasn't been produced. I want to check whether this file is present in a directory and if not, print the ...
1
vote
5answers
72 views

how to find mysql binary in redhat

I am working with a Redhat distribution. The network admin is inaccessible so I have no ability to request information. Using bash, how do I find the mysql binary so that I can run sql commands? ...
0
votes
2answers
90 views

find and replace multiple files using a file as input to find and another to replace

I need to replace several chunks of text inside some php scripts... i have: find . -name 'products.php' -exec grep --silent 'TEXT_TO_FIND' {} \; -exec ls {} \; -exec sed -i ...
1
vote
1answer
47 views

linux + mount from local dir [closed]

in my Linux machine I run the following command under from /usr/cti/APPS directory cd /usr/cti/APPS mount -t nfs $server:$target_dir /mnt I want to show something very interesting I can run ...
1
vote
1answer
482 views

/bin/sh: /bin/cp: Argument list too long

I have problem with this command: 'cp' -fr /www/*-aws/* /www/mainhost/aws/awstatstotals/tmp/ Error is Argument list too long - I know many /www/-aws/ folders. I know that I can use FIND command, ...
1
vote
3answers
88 views

linux: find files from a list in txt, the files contain spaces

I need to find files from a list in txt (i already have the txt with all the files, are separated with lines), the files contain spaces and the extension of the files are pdf, if you can suggest how ...
0
votes
3answers
76 views

How can I copy all files in one tree to another tree except those matching a pattern?

I have a directory tree under ./src/ I have another matching directory tree under ./work/ I'm trying to copy all the files in src to work, while keeping the directory structure and excluding all ...
0
votes
2answers
150 views

Bash/grep: ignore lines over N characters

I have a find/grep command that i use to search my projects' codebase, thus: find folder1 folder2 folderetc -print | awk '{print "\""$0"\""}' | xargs grep -n "search-string" Something that ...
0
votes
1answer
148 views

Cannot find home directory on Linux Server

I have recently been granted access to a Linux server where I transferred some data. Now, for some reason, when I use WinSCP or any other program to connect to the server, instead of logging in ...
0
votes
2answers
183 views

Find, chown and exclude directories

I would like to change the ownership of all files and directories but exclude some directories: find -user test ! -path "./dir1/*" ! -path "./dir2/*" -exec chown -R root:root {} \; The ownership of ...
0
votes
2answers
78 views

I accidently gave all my project files a .gz format, how to revert it?

So I've accidently gave all my files, php, js, html, css files a .gz ending, so they look like: .bowerrc.gz index.php.gz main.css.gz etc... Using Centos 6.4, how can I revert back all the files? ...
0
votes
3answers
289 views

Exclude with the find command [duplicate]

I need some help getting the find command to work right in a script working on. I need to be able to exclude some directories. Below I have what I'm doing as a work around. sudo find / ( -name ...
2
votes
1answer
81 views

How can i manipulate the find command to “find” the directories the “found” file is in?

So i'm trying to use the find command to find all files in my system with mtime -x. It does this but it does not "find" the directories of the file. find . -mtime -2 -exec rsync -av {} /destination/ ...
-2
votes
3answers
169 views

How to delete file by access time in linux? [closed]

I want to delete *.mp3 files that access time is older from 10 minutes in a directory. How can i do? Thanks.
1
vote
1answer
23 views

How to get a debug output from the find command?

I have the following find command: find /home/ -type d -name "something" what I want to achieve is to know which directory/file is checked by the find command no matter the fact that it does or ...
0
votes
1answer
74 views

Find and rename files removing suffix

I'm using the following command to move all files (non-recursively) ended in _128.jpg into the 128x160 subdir. This works great. find . -iname '*_128.jpg' | xargs -I '{}' mv {} 128x160 But I also ...
1
vote
2answers
304 views

linux command line find escape question mark

For some reason I would like to delete all files names like "*.jpg?" (the filename is ending with a real ?) I tried this find /var/www/ -type f -name "*.jpg\?" and find /var/www/ -type f -name ...
1
vote
0answers
79 views

Composer runtime error when deleting subdirectories

I am running 'composer install' on my server, and then using the script feature to delete all subdirectories called '.git' but I am running in the following composer error. Delete all .git dirs find: ...
1
vote
1answer
84 views

Find and replace files in linux

I know how to find and replace certain string through files, but I'm interested how could I find and replace whole files? e.g. I would like to find all info.php files that were modified at specific ...
0
votes
0answers
38 views

Clarifying what modifies atime and the impact the find command might have

So on a regular basis I clear out files from my server which have an atime +160 with a command such as: (technically to delete old files but avoid any file that might have been accessed recently) ...
1
vote
1answer
69 views

Results of not using '{}' in find /mnt/tmp -atime +91 -exec rm -f {} \;?

I have been using the following code for the longest on a system I took over: find /mnt/tmp -atime +91 -exec rm -f {} \; However, researching further I see everyone saying the curly braces should ...
0
votes
1answer
584 views

find directories in the current directory, older than 5 days and archive them

This is basic questions. I need to find folders in the current working directory(not recursively) and if they are older than 5 days archive them. zip or tar.gz is fine. I can find the folders with ...
0
votes
1answer
89 views

Unix 'find' command to include/exclude subdirectories

Say the folder structure looks like this: . |--folder1 |--subfolder1 |--subfolder2 |--subfolder2 |--folder2 |--subfolder1 |--subfolder2 |--subfolder2 |--folder3 ...
1
vote
1answer
69 views

How to find non-ports installations in FreeBSD?

Is there way to find all non-ports installations in FreeBSD? I'm using 8.4 version. Update: I need this for audit installed binaries for system "trusted" versions.
3
votes
1answer
78 views

How to list every file that is written to, on Linux?

What is the best way of getting a list of all files which have been written to, since power on? Is a simple find (with mtime) best for this, or are there other ways? (find won't list files which are ...
0
votes
1answer
34 views

Is there a tool for indexing a directory in order to perform cheap content search? (hashing by word, for example)

I am often using grep -R on an entire directory tree to find all files that contains a specified word. I wonder if there is a tool that makes the whole operation much faster, maybe via hashing? (Unix ...
1
vote
2answers
231 views

find: how to not have errors (stderr) when no files exists

I have a custom script which gzip log files when they are one day old. In my script all errors (stderr) are logged to a file and at the end of the script I use this file to know if its execution was ...
0
votes
2answers
1k views

How to rsync files / folders from a specific date forward?

I would like to rsync folders from a specific date and forward. for example. I want to rsync my folders that were created from 3 days ago (and of course 2 days ago, one day ago etc.). I know I need to ...
1
vote
4answers
2k views

How to properly pipe find with grep and cp in this use case

I am interested in recursively grepping for a string in a directory for a pattern and then cp'ing the matching file to a destination directory. I thought I could do something like the following, but ...
-4
votes
3answers
72 views

Is searching for a file on a live production server a bad idea? [closed]

On our live production server, we forgot which folder our website was stored in. My colleague asked me where it was. I did not know but suggested to just run a search for the folder name on the ...
1
vote
2answers
158 views

Deleting inserted content in multiple files on linux server

I often have problem with sites that get hacked. Usualy they end up with inserted script in different files. Is there a way, on linux, to search for this content and automaticaly delte it ? Usualy ...
1
vote
2answers
62 views

Fetching all PHP files and store their size

I like to monitor every php file with their size (and if a new file has been added). On my server are more than 200 000 of em so find takes very long. This is what I do: ls -1 --size $(find -P . ...
2
votes
1answer
104 views

How to safely change owner:group recursively?

I'm copying one users home directory to be the home directory of user #2, and therefore need to chown the contents to the new user. Running: find /home/user2 -user user1 -exec chown user2 '{}' \; ...
0
votes
1answer
86 views

find all end subdirectories in a tree

given the following structure: oz123@debian:~/ $ tree . . ├── a │   ├── a1 │   ├── a2 │   └── a3 ├── a1 │   ├── a11 │   ├── a12 │   └── a31 ├── b │   └── b1 │   ├── b11 │   │   └── b21 │   ...
3
votes
1answer
50 views

How to run a recursive chmod that stop at FileSystem Boundaries

I have a directory with lots of files and inside a mounted directory. var/ log/ nfs/ (a NFS remote directory) www/ How can I chmod/chown everyfiles inside that directory without changing ...
1
vote
0answers
103 views

Compress all apache log files which don't have any symlink pointing to them

I'm using cronolog to let the apache log files rotate. I'm using fail2ban to monitor those log files and ban in case of abuse. There's always an access.log symlink which is created by cronolog and ...
1
vote
3answers
232 views

List all php files inside a folder with modification date and permissions

I did write a script which checks all php files within a given folder for changes every hour, so I can detect possible code injections and their integrity. It's working so far, but my approach seems a ...
0
votes
2answers
63 views

Looking for a shell command to read non-binary part of most common image types

A website I'm hosting on my dedicated server has been hacked. Some pictures have been infected with things like <?php eval(base64_decode(....));?>. I'm looking for a generic shell command which ...
0
votes
2answers
394 views

UNIX ctime : how to keep this precious information in backups (tar)?

I have three questions related to the "ctime" information of a file. They are in bold (if you don't have time you can jump directly to them). A website on my dedicated server has been hacked. Lots ...
-4
votes
3answers
308 views

Find in all sub directories [closed]

I have a directory with many sub directories, I want to find a file in this directories so I use this command: find ./ -name test.php but this command search just in the top level directory, how ...
0
votes
1answer
94 views

Correctly predicting the amount of disk usage with find/ls/stat and df?

I'm trying to programatically calculate the number of files that can fit on a drive. The drive uses LUKS/ext4 and has a block size of 4096. Below is a df printout of the drive. Filesystem ...
4
votes
2answers
6k views

Move files to another directory which are older than a date

I am looking for a solution to move files that are year older from today. My log partition is getting full, but I can not remove them. They are needed for a long long time. Anyway one solution I came ...
1
vote
4answers
345 views

Auto-delete files after they've been on the server for 14 days

We have a Linux FTP server that clients and project managers upload files onto to exchange files. Unfortunately, nobody ever goes in and deletes anything when they're done with it. I'm looking for ...
2
votes
2answers
582 views

How do i use the {} operator in find execution inside exec

I tried this bash command: find /var/www/ -path '*wp-admin/index.php' -exec mv {} $(dirname {})/index_disabled But the second {} is not executed. It results in just ./index_disabled instead. How ...