Skip to main content

All Questions

0 votes
3 answers
372 views

find command with multiple pattern not returning any output

#!/bin/bash pat="'*.ab' -o -name '*.bc'" open="\(" close="\)" path=path find $path -type f $open -name $pat $close Above code doesn't show any output for find. Do help
Arjun's user avatar
  • 13
5 votes
1 answer
4k views

Find a file and make a symlink to parent using find and -exec

I am trying to use find to find files matching a certain pattern, and then symlink their parent directorys to another directory, this is my current script (I'm doing this on mac so -printf won't work ...
timhc22's user avatar
  • 163
1 vote
1 answer
3k views

find -exec not working in bash script but working in terminal [duplicate]

I am trying to write some bash script to replace a command I quite often use. Here is the code from my file test.sh #!/bin/bash echo -e "\n" i=0 args[i++]=$0 for arg in $@ ; do args[i++]=$arg done ...
Tsathoggua's user avatar
2 votes
1 answer
756 views

cp not evaluating dirname properly in find operation [duplicate]

I'm trying to create a script which will find files of a certain filename, copy a file to that file's location, and then delete the found file. Ignoring the delete part for now, this is what I have ...
user2509899's user avatar
1 vote
1 answer
799 views

Rewrite a find command that uses sed -i for AIX

I have a script that searches for a string and replaces it via the sed command. If that string contains special characters, the script will escape them (except for the slash because it's my current ...
Rich B. Goodman's user avatar
4 votes
4 answers
3k views

How to escape shell metacharacters automatically with `find` command?

I've got a bunch of XML files under a directory tree which I would like to move to corresponding folders with the same name within that same directory tree. Here is sample structure (in shell): ...
kenorb's user avatar
  • 21.9k
0 votes
2 answers
560 views

Recursively remove files with idx > 10,000

The problem In the current working directory I have several (very many) folders and some of them have lots (like 100,000+) of files inside. My goal is getting just the folder with 10,000+ files and ...
Atcold's user avatar
  • 1,593
2 votes
2 answers
7k 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 ...
Skittles's user avatar
  • 143