Thinking Out Loud

March 10, 2013

Linux Tips and Tricks

Filed under: linux — mdinh @ 4:23 am

find with regex

Version tested:

$ uname -a
Linux lax.localdomain 2.6.39-200.24.1.el6uek.x86_64 #1 SMP Sat Jun 23 02:39:07 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux

Find 1 directory below admin, directories adump, bdump, cdump, udump
File extensions: .aud, .trc, .trm
File size: zero byte
File name: sbtio.log
Print files deleted older that 1 day.

find /u01/app/oracle/admin/*/[abcu]dump -type f \( -name “*\.aud” -o -name “*\.tr[cm]” -o -size 0c -o -name “sbtio.log” \) -mtime +1 -print -exec rm {} \;

Example:

[oracle@lax:db01]/home/oracle
$ find /u01/app/oracle/admin/*/[abcu]dump -type f \( -name "*\.aud" -o -name "*\.tr[cm]" -o -size 0c -o -name "sbtio.log" \) -mtime +1 -print -exec rm {} \;
/u01/app/oracle/admin/db01/adump/db01_ora_1927_1.aud
/u01/app/oracle/admin/db01/adump/db01_ora_1937_1.aud
/u01/app/oracle/admin/db01/adump/db01_ora_1960_1.aud
/u01/app/oracle/admin/db01/adump/db01_ora_1987_1.aud
/u01/app/oracle/admin/db01/bdump/test.trc
/u01/app/oracle/admin/db01/bdump/t.1
/u01/app/oracle/admin/db01/udump/my.trc
/u01/app/oracle/admin/db01/udump/t.2

Find 2 directories below rdbms, directory trace

find /u01/app/oracle/diag/rdbms/*/*/trace -type f \( -name “*\.tr[cm]” -o -size 0c -o -name “sbtio.log” \) -mtime +1 -print -exec rm {} \;

Example:

[oracle@lax:db01]/home/oracle
$ find /u01/app/oracle/diag/rdbms/*/*/trace -type f \( -name "*\.tr[cm]" -o -size 0c -o -name "sbtio.log" \) -mtime +1 -print -exec rm {} \;
/u01/app/oracle/diag/rdbms/lax_db01/db01/trace/db01_vkrm_2033.trc
/u01/app/oracle/diag/rdbms/lax_db01/db01/trace/db01_j001_2313.trm
/u01/app/oracle/diag/rdbms/lax_db01/db01/trace/db01_arc0_2028.trm
/u01/app/oracle/diag/rdbms/lax_db01/db01/trace/db01_vkrm_2305.trm
/u01/app/oracle/diag/rdbms/lax_db01/db01/trace/db01_ckpt_2137.trc
/u01/app/oracle/diag/rdbms/lax_db01/db01/trace/db01_dm00_2223.trc
/u01/app/oracle/diag/rdbms/lax_db01/db01/trace/db01_dbrm_1942.trm

Find and remove directory cdmp*, core*

find /u01/app/oracle/admin/*/[bc]dump -type d \( -name “cdmp*” -o -name “core*” \) -mtime +1 -print -exec rm -rf {} \;

Example:

[oracle@lax:db01]/home/oracle
$ find /u01/app/oracle/admin/*/[bc]dump -type d \( -name "cdmp*" -o -name "core*" \) -mtime +1 -print -exec rm -rf {} \;
/u01/app/oracle/admin/db01/cdump/cdmp
find: `/u01/app/oracle/admin/db01/cdump/cdmp': No such file or directory
/u01/app/oracle/admin/db01/cdump/core1
find: `/u01/app/oracle/admin/db01/cdump/core1': No such file or directory

Find and delete files NOT new than the provided file
find . \( ! -newer db01_ora_1937_2.aud \) -print -exec rm {} \;

Example:

[oracle@lax:db01]/u01/app/oracle/admin/adump
$ ls -alrt
total 376
-rw-r----- 1 oracle oinstall  763 Feb 27 22:26 db01_ora_6746_2.aud
-rw-r----- 1 oracle oinstall  763 Feb 27 22:30 db01_ora_6851_2.aud
-rw-r----- 1 oracle oinstall  769 Feb 27 22:30 db01_ora_6898_1.aud
-rw-r----- 1 oracle oinstall  970 Feb 28 07:09 db01_ora_6918_1.aud
-rw-r----- 1 oracle oinstall  765 Feb 28 07:11 db01_ora_31831_2.aud
-rw-r----- 1 oracle oinstall  771 Feb 28 07:11 db01_ora_31865_1.aud
-rw-r----- 1 oracle oinstall  775 Feb 28 07:11 db01_ora_31870_1.aud
-rw-r----- 1 oracle oinstall  763 Feb 28 09:44 db01_ora_1950_2.aud
-rw-r----- 1 oracle oinstall  769 Feb 28 09:44 db01_ora_1984_1.aud
-rw-r----- 1 oracle oinstall  773 Feb 28 09:44 db01_ora_1989_1.aud
drwxr-xr-x 4 oracle oinstall 4096 Feb 28 09:52 ..
-rw-r----- 1 oracle oinstall  763 Mar  2 22:11 db01_ora_1976_2.aud
-rw-r----- 1 oracle oinstall  769 Mar  2 22:11 db01_ora_2010_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:11 db01_ora_2015_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:22 db01_ora_2078_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:22 db01_ora_2079_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:22 db01_ora_2080_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:22 db01_ora_2081_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:22 db01_ora_2082_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:22 db01_ora_2083_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:22 db01_ora_2088_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:22 db01_ora_2089_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:24 db01_ora_2090_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:24 db01_ora_2091_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:24 db01_ora_2092_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:26 db01_ora_2097_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:26 db01_ora_2098_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:26 db01_ora_2099_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:26 db01_ora_2100_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:26 db01_ora_2101_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:26 db01_ora_2102_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:26 db01_ora_2103_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:26 db01_ora_2104_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:26 db01_ora_2105_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:26 db01_ora_2106_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:26 db01_ora_2107_1.aud
-rw-r----- 1 oracle oinstall  970 Mar  2 22:27 db01_ora_2111_1.aud
-rw-r----- 1 oracle oinstall  763 Mar  2 22:28 db01_ora_2112_2.aud
-rw-r----- 1 oracle oinstall  769 Mar  2 22:28 db01_ora_2146_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:28 db01_ora_2152_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:28 db01_ora_2180_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:28 db01_ora_2181_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:28 db01_ora_2182_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:28 db01_ora_2183_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:28 db01_ora_2184_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:28 db01_ora_2185_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:28 db01_ora_2190_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:28 db01_ora_2191_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:28 db01_ora_2192_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:28 db01_ora_2193_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  2 22:28 db01_ora_2194_1.aud
-rw-r----- 1 oracle oinstall  763 Mar  4 07:15 db01_ora_1987_2.aud
-rw-r----- 1 oracle oinstall  768 Mar  4 07:15 db01_ora_2021_1.aud
-rw-r----- 1 oracle oinstall  968 Mar  4 07:16 db01_ora_2026_1.aud
-rw-r----- 1 oracle oinstall  763 Mar  4 20:27 db01_ora_1927_2.aud
-rw-r----- 1 oracle oinstall  769 Mar  4 20:27 db01_ora_1961_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  4 20:27 db01_ora_1966_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  4 20:29 db01_ora_2010_2.aud
-rw-r----- 1 oracle oinstall  970 Mar  4 22:37 db01_ora_2445_1.aud
-rw-r----- 1 oracle oinstall  763 Mar  5 22:01 db01_ora_1960_2.aud
-rw-r----- 1 oracle oinstall  769 Mar  5 22:01 db01_ora_1994_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  5 22:01 db01_ora_1999_1.aud
-rw-r----- 1 oracle oinstall  970 Mar  5 23:12 db01_ora_2160_1.aud
-rw-r----- 1 oracle oinstall  763 Mar  6 06:28 db01_ora_1937_2.aud
-rw-r----- 1 oracle oinstall  769 Mar  6 06:28 db01_ora_1971_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 06:28 db01_ora_1976_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 06:29 db01_ora_2022_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 06:31 db01_ora_2046_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 06:33 db01_ora_2063_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 06:35 db01_ora_2071_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 06:35 db01_ora_2073_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 06:45 db01_ora_2103_2.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 06:45 db01_ora_2111_2.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 06:46 db01_ora_2120_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 06:48 db01_ora_2132_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 06:52 db01_ora_2165_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 06:59 db01_ora_2189_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 07:00 db01_ora_2194_2.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 07:01 db01_ora_2219_1.aud
-rw-r----- 1 oracle oinstall  970 Mar  6 07:31 db01_ora_2260_1.aud
-rw-r----- 1 oracle oinstall  763 Mar  7 20:48 db01_ora_1956_2.aud
-rw-r----- 1 oracle oinstall  769 Mar  7 20:48 db01_ora_1990_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  7 20:48 db01_ora_1995_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  7 20:51 db01_ora_2045_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  7 20:53 db01_ora_2058_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  7 20:54 db01_ora_2067_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  7 20:56 db01_ora_2081_2.aud
-rw-r----- 1 oracle oinstall  773 Mar  7 20:57 db01_ora_2094_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  7 20:59 db01_ora_2112_1.aud
-rw-r----- 1 oracle oinstall  970 Mar  7 21:45 db01_ora_2546_1.aud
-rw-r----- 1 oracle oinstall  763 Mar  9 19:32 db01_ora_2353_2.aud
-rw-r----- 1 oracle oinstall  769 Mar  9 19:32 db01_ora_2387_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  9 19:32 db01_ora_2392_1.aud
drwxr-xr-x 2 oracle oinstall 4096 Mar  9 19:32 .
[oracle@lax:db01]/u01/app/oracle/admin/adump
$ find . \( ! -newer db01_ora_1937_2.aud \) -print -exec rm {} \;
./db01_ora_2091_1.aud
./db01_ora_2160_1.aud
./db01_ora_31865_1.aud
./db01_ora_2015_1.aud
./db01_ora_2097_1.aud
./db01_ora_2180_1.aud
./db01_ora_2107_1.aud
./db01_ora_2191_1.aud
./db01_ora_6918_1.aud
./db01_ora_1976_2.aud
./db01_ora_2194_1.aud
./db01_ora_2090_1.aud
./db01_ora_2081_1.aud
./db01_ora_2192_1.aud
./db01_ora_2079_1.aud
./db01_ora_2152_1.aud
./db01_ora_2083_1.aud
./db01_ora_2182_1.aud
./db01_ora_2105_1.aud
./db01_ora_2104_1.aud
./db01_ora_1994_1.aud
./db01_ora_2181_1.aud
./db01_ora_1927_2.aud
./db01_ora_6851_2.aud
./db01_ora_2102_1.aud
./db01_ora_6746_2.aud
./db01_ora_2078_1.aud
./db01_ora_1960_2.aud
./db01_ora_1937_2.aud
./db01_ora_1989_1.aud
./db01_ora_2193_1.aud
./db01_ora_2082_1.aud
./db01_ora_2146_1.aud
./db01_ora_2183_1.aud
./db01_ora_2101_1.aud
./db01_ora_2184_1.aud
./db01_ora_2111_1.aud
./db01_ora_1984_1.aud
./db01_ora_1987_2.aud
./db01_ora_2112_2.aud
./db01_ora_31831_2.aud
./db01_ora_2021_1.aud
./db01_ora_2106_1.aud
./db01_ora_1966_1.aud
./db01_ora_2010_1.aud
./db01_ora_2103_1.aud
./db01_ora_2190_1.aud
./db01_ora_2089_1.aud
./db01_ora_2098_1.aud
./db01_ora_2088_1.aud
./db01_ora_2099_1.aud
./db01_ora_2080_1.aud
./db01_ora_31870_1.aud
./db01_ora_2185_1.aud
./db01_ora_2010_2.aud
./db01_ora_2092_1.aud
./db01_ora_2026_1.aud
./db01_ora_1950_2.aud
./db01_ora_6898_1.aud
./db01_ora_2100_1.aud
./db01_ora_1999_1.aud
./db01_ora_2445_1.aud
./db01_ora_1961_1.aud
[oracle@lax:db01]/u01/app/oracle/admin/adump
$ ls -alrt
total 124
drwxr-xr-x 4 oracle oinstall 4096 Feb 28 09:52 ..
-rw-r----- 1 oracle oinstall  769 Mar  6 06:28 db01_ora_1971_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 06:28 db01_ora_1976_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 06:29 db01_ora_2022_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 06:31 db01_ora_2046_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 06:33 db01_ora_2063_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 06:35 db01_ora_2071_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 06:35 db01_ora_2073_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 06:45 db01_ora_2103_2.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 06:45 db01_ora_2111_2.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 06:46 db01_ora_2120_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 06:48 db01_ora_2132_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 06:52 db01_ora_2165_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 06:59 db01_ora_2189_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 07:00 db01_ora_2194_2.aud
-rw-r----- 1 oracle oinstall  773 Mar  6 07:01 db01_ora_2219_1.aud
-rw-r----- 1 oracle oinstall  970 Mar  6 07:31 db01_ora_2260_1.aud
-rw-r----- 1 oracle oinstall  763 Mar  7 20:48 db01_ora_1956_2.aud
-rw-r----- 1 oracle oinstall  769 Mar  7 20:48 db01_ora_1990_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  7 20:48 db01_ora_1995_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  7 20:51 db01_ora_2045_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  7 20:53 db01_ora_2058_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  7 20:54 db01_ora_2067_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  7 20:56 db01_ora_2081_2.aud
-rw-r----- 1 oracle oinstall  773 Mar  7 20:57 db01_ora_2094_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  7 20:59 db01_ora_2112_1.aud
-rw-r----- 1 oracle oinstall  970 Mar  7 21:45 db01_ora_2546_1.aud
-rw-r----- 1 oracle oinstall  763 Mar  9 19:32 db01_ora_2353_2.aud
-rw-r----- 1 oracle oinstall  769 Mar  9 19:32 db01_ora_2387_1.aud
-rw-r----- 1 oracle oinstall  773 Mar  9 19:32 db01_ora_2392_1.aud
drwxr-xr-x 2 oracle oinstall 4096 Mar  9 19:33 .
About these ads

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Rubric Theme. Create a free website or blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 314 other followers

%d bloggers like this: