search for files in a directory hierarchy

learn more… | top users | synonyms

0
votes
2answers
16 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
1answer
18 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
32 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
27 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 ...
1
vote
2answers
293 views

How to find any file that is an executable or library

Let's say someone provides you with a tarball, saying it is source code and nothing else. You want to make sure that is true, and that no virus-laden executables or libraries are tucked away in a ...
0
votes
2answers
57 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? ...
2
votes
0answers
27 views

Symlink all subdirectories in a directory to another directory [migrated]

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 ...
0
votes
3answers
79 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
28 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
66 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
37 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
63 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
23 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: ...
4
votes
5answers
1k views

Linux find command - show progress

I was wondering if there's any way to display some kind of progress info when searching for files in linux using find. I often find myself searching for files on a big disk and some kind of progress ...
1
vote
1answer
50 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 ...
9
votes
7answers
11k views

Linux: using find to locate files older than <date>

find has good support for finding files the more modified less than X days ago, but how can I use find to locate all files modified after a certain date? I can't find anything in the find man page to ...
0
votes
0answers
17 views

error while using find command [duplicate]

I have a directory with over 2.5 million files and I want to delete them. Using the rm command was impossible. I did read that find command is the best, but I do not understand how to use it. This ...
0
votes
0answers
21 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
41 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
66 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 ...
0
votes
1answer
66 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
31 views

Unix 'find' command to include/exclude subdirectories

Say the folder structure looks like this: . |--folder1 |--subfolder1 |--subfolder2 |--subfolder2 |--folder2 |--subfolder1 |--subfolder2 |--subfolder2 |--folder3 ...
0
votes
1answer
33 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
1answer
66 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
75 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 ...
1
vote
2answers
81 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
1answer
151 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 ...
2
votes
4answers
3k views

How to restrict find command search to return only files modified before certain date?

I'd like to constrain the following search to only files with a modified date <= "2009-05-29 11:59:00" find /path -name "*.sb" ! -name "*[^0-9]*.sb" -type f -print I'm using CentOS
1
vote
4answers
380 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
70 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
153 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 ...
13
votes
4answers
5k views

Bash find command verbose output

Good time of the day, Is there way to tell the bash "find" command to output what it is doing (verbose mode) ? For example for the command: find /media/1Tb/videos -maxdepth 1 -type d -mtime +7 -exec ...
2
votes
2answers
1k views

find files NOT belonging to group

How do I find files not belonging to particular group? find /home -group NOT test
20
votes
8answers
36k views

how to find out mac addresses of all machines on network

Is there some easy way to find out mac address of all machines on my network rather than doing an SSH into each and ifconfig | grep HWaddr if there are 300 machines on network I really need some easy ...
1
vote
2answers
58 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 . ...
4
votes
1answer
4k views

How do I find circular symbolic links?

I'm working on a HP-UX system and I want to find if there are any circular symbolic links. So far I'm using the command: ls -lrt `find ./ -follow -type l` But it's only doing ls -lrt on current ...
2
votes
1answer
76 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
54 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
30 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 ...
0
votes
0answers
55 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 ...
0
votes
3answers
129 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
48 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
273 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 ...
1
vote
4answers
181 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 ...
-4
votes
3answers
142 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 ...
2
votes
6answers
2k views

Remove path from find command output

I have a bash script for deploying code from a beta environment to a production environment but currently I have to add the list of files to a txt file manaully and sometime I miss some. Basically my ...
2
votes
2answers
1k views

How can I use netsh to find a rule using a pattern

I'm wondering whether anyone in Microsoft has ever come to a situation where they can't remember a rule's name! The netsh advfirewall firewall show rule only accepts 1 name and no pattern matching ...
2
votes
3answers
3k views

Why does FIND on Windows 7 give an “Access Denied” error?

I have an administrator account on a Windows 7 x64 machine. It is not THE administrator account, the account is simply a member of the administrators group. The install is default. When the user ...
2
votes
2answers
628 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 ...