Hi nezabudka,
Note that most Solaris systems don't have the -regex, -path, and -not primaries.
Hi snowfrost88,
The find command that you're using has two groups of primaries separated by a logical OR operator (-o). The first group of primaries is just -name "*.txt". This group essentially finds all files with names ending with .txt and ignores them. The second group finds all files with names ending with .err that have been modified in the last 30 days that are not directories and that have the name ./b and moves all files that meet all of those requirements to the file named ./c (which we hope, but have not verified, is a file of type directory). Since no filename can ever contain a <slash> character, no filename can ever be selected by the -name ./b primary (and, therefore, no files will ever be moved by this command).
In addition to the problem noted above, I assume that what you're really trying to do is to move all files that have been modified within the last 30 days that either have a name ending in .txt or ending in .err that are not located in or under a directory named either b or c into the directory named c without duplicating any of the file hierarchy structure into the directory c. If that assumption is correct, you probably want something more like:
Note the sets of \( and \) grouping operators to alter the precedence the logical OR operators and the -prune primary to ignore all files under directories named b or c when selecting regular files with the extensions .txt and .err.
Last edited by Don Cragun; 12-04-2018 at 03:18 AM..
Reason: Add note explaining why nezabudka's suggestion won't work.
This User Gave Thanks to Don Cragun For This Post:
How to get the name of the file by excluding the extention of file name?
For example, my filename is 'test.txt'. I want to get only the name 'test' but not the extention .txt. (2 Replies)
Hi
I have some 5 folders and two files in the current directory.
I want to delete all, expect one folder(files in the folder too should not be deleted) and a file in the current directory. Lets say the folder and file that should not be deleted as 'a'(folder name) and 'b'(file name). Can you... (1 Reply)
Hi,
I have a filename Location.txt in a directory /abc.
Similar name file is present in its subdirectory /abc/xyz.
I want to find the file which is present only in /abc and not in /abc/xyz.
Please any1 of u can provide a quick suggestion.
Its very urgent.
Thanks,
Amol (2 Replies)
Hello,
Under one directory, I can use below command to find out the file names with string "Export terminated successfully without warnings"
grep -i -l "Export terminated successfully without warnings" *.*
My question is : how I find out the file names without including string
"Export... (5 Replies)
Hi,
I have a directory structure as below
/home/gad/Merl/a/a1.txt
/home/gad/Merl/b/a1.txt
/home/gad/Merl/c/a1.txt
How can I find the file a1.txt but not from directory 'a' and it(the filw) should loaded 6 days ago..
Can any one pls help,quick reply much appriciated..
Thanks. (1 Reply)
I have been searching, and cannot find an answer for this. I am trying to find all files for a user, lets call him (test001), and I want to exclude a specific directory.
Here is the command I run, it finds all files:
find / -user test001
I get this result:
> find / -user test001 ... (4 Replies)
hi,
I need to find files that have been created less than 3 days ago. However, I need to only search specific directories.
I've searched about the net and found some useful commands such as :
find . -type d -name 'dir_to_exclude' -prune -o -print -mtime -3
however I cannot get it... (2 Replies)
Hi Forum,
I am using the below command to find files older than x days in a directory excluding subdirectories. From the previous forums I got to know that prune command helps us not to descend in subdirectories. Though I am using it here, not getting the desired result.
cd $dir... (8 Replies)
Find all files in the current directory only excluding hidden directories and files.
For the below command, though it's not deleting hidden files.. it is traversing through the hidden directories and listing normal which should be avoided.
`find . \( ! -name ".*" -prune \) -mtime +${n_days}... (7 Replies)
Hi All,
requirement is to find and remove the files from sub directories but it should exclude the files from parent directory.
At present i am using the below one but it finds and remove files from both parent and sub directories.
find ${PATH} -type f \( -name securitas\* -o -name \*gz... (1 Reply)