0
votes
3answers
44 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
69 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
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 ...
0
votes
3answers
163 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 ...
2
votes
2answers
309 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
105 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 ...
2
votes
3answers
293 views

find and remove duplicates filenames in directory hierarchy

#!/bin/sh LASTBASE="" find $1 -type f -print | rev | sort | rev | while read FILE do BASE=$(basename "$FILE") if [ "$BASE" = "$LASTBASE" ]; then rm "$FILE" LASTBASE="$BASE" done ...
3
votes
4answers
904 views

How to do a for loop of filenames with spaces using find

I have the following script - its supposed to loop files names using find but it seams to break the files names up by a space? I need the file names to remain intact #!/bin/bash for file in `find ...
2
votes
3answers
364 views

find count of images within a directory

I wanted to find the number of image files within a directory. I ended up using this : find . -type f -exec file {} \; | grep -c -i 'image' This feels like an inefficient way of doing it. I could ...
2
votes
7answers
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 ...
13
votes
4answers
6k 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 ...
6
votes
3answers
2k views

Non-recursive find on linux

I am trying to find all directories that are directly inside the current directory and older than a specific age. The trick is, I only want to consider the age of the immediate descendants of the ...
2
votes
4answers
707 views

How to bulk rename files to remove an extraneous space from before the extension

I have a bunch of files who's filename follows the pattern 'filename.ext'. eg: filename .ext I would like to rename all of these to remove the space before the .ext. eg: filename.ext I can find ...
4
votes
2answers
311 views

Difficult to Delete Files in Linux

There's a lot of stuff about this on the Internet, but most of the examples there are contrived. How does one delete files that are really stubborn? e.g., $ find ./ -inum 167794 ./àKÈÿÿÿÿ@ $ find ...
4
votes
3answers
2k views

finding a file which was modified in last 10 minutes

I am running this command to find out the files which were modified in last 10 minutes find / -fstype local -mtime -10m but it is giving following error each time find: missing argument to ...
3
votes
3answers
369 views

find files their name is smaller or greater than a given parameter

Say that in a given directory I got tzury@x200:~/Desktop/sandbox$ ls -l total 20 drwxr-xr-x 2 tzury tzury 4096 2011-03-09 10:19 N00.P000 drwxr-xr-x 2 tzury tzury 4096 2011-03-09 10:19 N00.P001 ...
7
votes
4answers
1k views

Bash: execute command on results of FIND

I am trying to resize all files that are found using a FIND command (they are all files within a directory and its subdirectories). I tried many options but stumble across different errors each time. ...
3
votes
3answers
678 views

sh script to remove just txt files using find and exec rm warns me of missing argument to exec

find /full/path/dir -name '*.txt' -exec /bin/rm {} \; Fine in a shell, but pop it in a sh script along with some similar lines, to get it to run nightly from a cronjob, and it reports: find: ...
1
vote
2answers
1k views

Recursively rename files using find and sed

I want to go through a bunch of directories and rename all files that end in _test.rb to end in _spec.rb instead. It's something I've never quite figured out how to do with bash so this time I thought ...
0
votes
1answer
398 views

Finding/deleting top level folders not containing any files

I want to delete the top level directory which does not contain any files, but can contain other empty (meaning again not containing files) directories. For example: $ ls -R .: foo/ ./foo/: bar bar1 ...
1
vote
2answers
198 views

Multiple command executions from find

Most people are familiar with using find to run the same command on a number of files, e.g.: find -type f | xargs command or find -type f -exec command {} \; My question is whether it's possible ...
0
votes
2answers
175 views

File name using find

How to get the file name while using find command? When I use find command to search particular type of files from a directory and subdirectories, I get the whole path of that file, how do I get the ...
1
vote
3answers
3k views

mass mv using find?

there are a bunch of filename.gif scattered in /home/ directories. I want all the filename.gif replaced by a /home/shared/filename_default.gif. I tried something like find /home/ -name ...
2
votes
2answers
417 views

Bash script to create mass series of directories

I need to create a Bash script to go into every user's home folder, seek out a wp-content folder, create a directory uploads under it, and then chmod 0756 uploads. How do I achieve this? I imagine I ...
3
votes
4answers
1k views

Find directories that do not contain a directory?

I'm trying to figure out how to use the linux "find" command (or another command that will get the job done) to return a list of file paths/directories that do not contain a directory of a certain ...
2
votes
1answer
273 views

Find only top directories matching search

I'm trying to find all the web folders that are 777. But I only want a list of the top folders. So if there is an img dir that has folders in it that are also 777 I don't want them returned. ...
3
votes
3answers
795 views

help with bash script using find and diff command

i have a bash script that i need help with: #!/bin/bash if [ -f "/suid.old" ] then find / -perm -4000 -o -perm -2000 ls > suid.old else find / -perm 4000 -o -perm -2000 ls > suid.new diff ...
14
votes
4answers
9k views

Shell Scripting: Using find to delete files matching a pattern

I'm trying to write a bash command that will delete all files matching a specific pattern - in this case, it's all of the old vmware log files that have built up. I've tried this command: find . ...