Bash find with expression - process all files except the starting-points


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash find with expression - process all files except the starting-points
# 1  
Bash find with expression - process all files except the starting-points

Hello.
This command is correct :
Code:
find /home/user_install \( \
    \( -type d \( -iname "*firefox*"  -o -iname ".cache" -o -iname "libreoffice"  \
        -o -iname "session" -o -wholename "/home/user_install/dir1/dir2/¬¬ICONS_WALLPAPERS_THEMES" \)  \) -prune -o \
    \( -type f \( -iname "*.iso" -o -iname "*.png" -o -iname "*.jpg" \
        -o -iname "*.log*" -o -iname "*.run" \) \) -prune -o \
    \( ! -newer /run/media/user_install/BESTRUNNER-8Go-14/NEW_INSTALL_SYSTEM/HOME_USER_INSTALL_4-skel-file-change-flag/foo_ref_date_2019_11_18_16h_41m_00s.txt \) -prune  \) -o -print

Code:
user_install@ASUS-G750JZ-JC:~> ~/test_027.sh
/home/user_install
/home/user_install/.config
/home/user_install/.config/startupconfigkeys
/home/user_install/.config/kdeglobals
/home/user_install/.config/startupconfig
/home/user_install/.config/startupconfigfiles
/home/user_install/.config/gtkrc
/home/user_install/.config/gtkrc-2.0
....................
/home/user_install/test_025.sh
/home/user_install/error_log.txt
/home/user_install/test_020.sh
/home/user_install/test_021.sh

Now I would like to remove result coming from starting point.

The following should be removed :

Code:
/home/user_install/test_025.sh
/home/user_install/error_log.txt
/home/user_install/test_020.sh
/home/user_install/test_021.sh

I have tried to put -mindepth 1 in different places but that does not work :
Code:
find /home/user_install  -mindepth 1 \(  \
..........
 ..........

Do not change output
Code:
/home/user_install/test_025.sh
/home/user_install/error_log.txt
/home/user_install/test_020.sh
/home/user_install/test_021.sh

or

Code:
find /home/user_install  \( \
     \( -mindepth 1 \) \
..........................

give a warning :
Code:
find: warning: you have specified the -mindepth option after a non-option argument (, but options are not positional (-mindepth affects tests specified before it as well as those specified after it).  Please specify options before other arguments.

Or does not work at all ( .cache should be exclude )
Code:
 ...........
 ...........
/home/user_install/.cache/mesa_shader_cache
/home/user_install/.cache/mesa_shader_cache/index
/home/user_install/.cache/mesa_shader_cache/78
/home/user_install/.cache/mesa_shader_cache/78/ba03e85b7c39a151259121010c6c8d3b6243a3
...........

 /

Any help is welcome
# 2  
-mindepth is a global/scope option and must be first.
Code:
find /home/user_install -mindepth 2 ...

Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #1006
Difficulty: Medium
In calculus and most other branches of mathematics beyond practical geometry, angles are universally measured in degrees.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to find regular expression for two files?

I have files: sum_<INPUT FILENAME>.YYYYMMDDhhmmss.csv and sum_details_<INPUT FILENAME>.YYYYMMDDhhmmss.csv I have no idea, what is input filename, but in the code I would like to catch them in case I process them in the loop above case statement for *.${Today}.*.txt... (3 Replies)
Discussion started by: digioleg54
3 Replies

2. Shell Programming and Scripting

Bash-awk to process thousands of files

Hi to all, I have thousand of files in a folder with names with format "FILE-YYYY-MM-DD-HHMM" for what I want to send the following AWK command awk '/Code.*/' FILE-2014* I'd like to separate all files that have the same date to a folder named with the corresponding date. For example, if I... (7 Replies)
Discussion started by: Ophiuchus
7 Replies

3. UNIX for Dummies Questions & Answers

Im new to bash scriping and i found this expression on a bash script what does this mean.

# check host value regex='^(||1|2|25)(\.(||1|2|25)){3}$' if ')" != "" ]; then if ]; then echo host $host not found exit 4 fi elif ]; then echo $host is an invalid host address exit 5 fi espeacailly the top regex part? ---------- Post updated at 06:58 PM ---------- Previous update was... (1 Reply)
Discussion started by: kevin298
1 Replies

4. Shell Programming and Scripting

search a regular expression and match in two (or more files) using bash

Dear all, I have a specific problem that I don't quite understand how to solve. I have two files, both of the same format: XXXXXX_FIND1 bla bla bla bla bla bla bla bla bla bla bla bla ======== (return) XXXXXX_FIND2 bla bla bla bla bla bla (10 Replies)
Discussion started by: TheTransporter
10 Replies

5. UNIX for Dummies Questions & Answers

Find the process and their files

Hi all, when i run a program in a Linux, it may call bunch of other files. How do i find those files? thanks in adanvance Sajith (1 Reply)
Discussion started by: email2sajith
1 Replies

6. UNIX for Dummies Questions & Answers

Find files that don't match expression

How Do I find all files in /home that are not .jpgs? (5 Replies)
Discussion started by: glev2005
5 Replies

7. Shell Programming and Scripting

[KSH/Bash] Starting a parent process from a child process?

Hey all, I need to launch a script from within 2 other scripts that can run independently of the two parent scripts... Im having a hard time doing this, if anyone knows how please let me know. More detail. ScriptA (bash), ScriptB (ksh), ScriptC (bash) ScriptA, launches ScriptB ScirptB,... (7 Replies)
Discussion started by: trey85stang
7 Replies

8. Shell Programming and Scripting

Use Perl In Bash Script To Compare Floationg Points

Is there a way to compare two floating points numbers in a bash script using perl? I've tried just using a bash if statement and it doesn't seem to support floating point numbers. Can the perl line read vars from bash then output a var to bash? a=1.1 #from bash b=1.5 #from bash if... (3 Replies)
Discussion started by: Grizzly
3 Replies

9. Shell Programming and Scripting

starting a bash session as child process to another bash session from a process

Hi I want to do something that might sound strange. I have a code that in written in C and is executed at startup (it's a custom process). It occasionally calls some bash scripts. The process doesn't have any terminal associated with it. One thing I don't know how to do is to start a... (5 Replies)
Discussion started by: alirezan
5 Replies

10. Shell Programming and Scripting

capture the process id when starting a background process

Hello all, How do I start a background process and save the process id to a file on my system. For example %wait 5 & will execute and print the process id. I can't figure out how to get it to a file. I've tried: > filename 0>filename 1>filename. Any assistance is most appreciated. Thanks, Jim... (10 Replies)
Discussion started by: jleavitt
10 Replies

Featured Tech Videos