search for files in a directory hierarchy

learn more… | top users | synonyms

-1
votes
0answers
9 views

find, tar and specific directories

I'm having a hard time completing a command. I want to use find to find specific files in specific folders and then pipe them to tar and compress them. The tricky part is, that I need to iterate ...
1
vote
5answers
39 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
44 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 ...
0
votes
1answer
35 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
233 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
67 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
47 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
76 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
64 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
49 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
68 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
118 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
43 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
87 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
49 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
138 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
56 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
65 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
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
31 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
57 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
172 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
47 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
68 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
77 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
137 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
399 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
759 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
156 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
93 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
67 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
42 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
73 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
172 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
52 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
326 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
185 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
80 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 ...
2
votes
2answers
2k 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
231 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
325 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 ...
0
votes
1answer
108 views

Recursively delete empty folders with verbose output

This should be fairly simple, but I am not sure what i'm missing. I'd like to recursively delete empty directories, and get an output for what's being deleted, this command works for sure, but I just ...
0
votes
2answers
1k views

Linux Find and Zip Files

I'm running into 2 problems when working with my logs and the find command. I am having problems with the mtime option. The 1st command below shows me a few files from March 5th till March 7th, like ...
2
votes
1answer
82 views

RSYNC Slow / Copy only changed files?

I have a server that maintains thousands of log files that are nested in thousands of directories. At the moment, I am using RSYNC to copy those log files to a web server where I parse them and make ...
1
vote
1answer
98 views

find … -exec command not executing on all files found

How come this command: find . -name \*.css -o -name \*.php -type f gives me a list of all the *.css and *.php files BUT adding the 'exec' option: find . -name \*.css -o -name \*.php -type f -exec ...
0
votes
0answers
39 views

Can slocate include file sizes?

I want to get a list of the large files on my system but I don't want to have to run the find command to produce this year. Can the slocate command be used to include file size information? I don't ...