Under /var/log/hive we have a lot of log files  we want to remove all files exclude the following that should be not removed   hivemetastore.log hiveserver2-report.json.tmp hivemetastore-report.json.tmp
123952
I want to remove all files in a directory while leaving just some specified files, they don't have anything in common by name. How could I achieve that?  For example, the file names I want to keep are:  file_1.png, another_file.jpg, some_music.mp3
22146
My top-level directory is data. data includes several directories and these directories have sub-directories. I need to remove all files and directories inside data/ except several files in some directories.   For example, data includes the directories 100 and 101. I just want to keep a.txt and b.txt files in 100/ and c.txt and d.txt files in 101/ while removing all other files and directories in 100 and 101.  Example:  . ├── 100 │   ├── a.txt │   ├── b.txt │   ├── c.txt │   └── d.txt └── 101     ├── a.txt     ├── b.txt     ├── c.txt     └── d.txt   I use rm -rf !(a.txt|b.txt) command but I can't apply this command for each directory automatically.
14519
I have a bunch of files as follows:  04602635_b0294.DAT20120807164534 04602637_b0297.DAT20120807164713 04602638_b0296.DAT20120807164637 04602639_b0299.DAT20120807164819 04602640_b0298.DAT20120807164748 04602641_b0300.DAT20120807164849 04602650_b0301.DAT20120807164921 04602652_b0302.DAT20120807164956   I need to rename them to exclude the prefix. It needs to look like this..  b0294.DAT20120807164534 b0297.DAT20120807164713 b0296.DAT20120807164637 b0299.DAT20120807164819 b0298.DAT20120807164748 b0300.DAT20120807164849 b0301.DAT20120807164921 b0302.DAT20120807164956   EDIT  I forgot to add that I am using Solaris.
41853
I want to remove all the files from different directories, and want to keep only latest files 20 files. is this the correct command to do this?  ls -t1 /mnt/dwh/ftp/dwh_ftp_cbs/ARLOGS/ | tail -n +22 | xargs rm -f
14457
I'm trying to get rid of everything before the filename ex:  /home/mike/whatever/test_1.txt   leaving only test_1.txt  what would the simplest way?  thanks
37622
I have a directory containing a large number of files. I want to delete all files except for file.txt . How do I do this?  There are too many files to remove the unwanted ones individually and their names are too diverse to use * to remove them all except this one file.  Someone suggested using   rm !(file.txt)   But it doesn't work. It returns:  Badly placed ()'s    My OS is Scientific Linux 6.  Any ideas?
72111
Delete all option in Debug log deletes the log page-wise. Is there any option to delete all the logs in debug at an instance?
83088
Is there an MS-DOS command that allows me to delete all files except one?  Consider as an example the following files:  a.001   a.002   a.003   a.exe   a.c     Is there a command to delete all files except a.c?
37704
I am on Linux (Ubuntu) and I am would like to exclude certain directories (like .hg) when I am doing a  find | less     I tried the following to exclude the .hg directory from listing, but does not seem to work.  find -type d \( ! -iname \.hg \) find -type d \( ! -name \.hg \) find -type d \( ! -iname .hg \)   How do I exclude .directory in a find command
68055
How does one find large files that have been deleted but are still open in an application? How can one remove such a file, even though a process has it open?  The situation is that we are running a process that is filling up a log file at a terrific rate. I know the reason, and I can fix it. Until then, I would like to rm or empty the log file without shutting down the process.   Simply doing rm output.log removes only references to the file, but it continues to occupy space on disk until the process is terminated. Worse: after rming I now have no way to find where the file is or how big it is! Is there any way to find the file, and possibly empty it, even though it is still open in another process?  I specifically refer to Linux-based operating systems such as Debian or RHEL.
103456
I want to create a shell script that deletes old release files except last n files. In other words, only mantain last n releases when I deploy a new release.  File names have this format:  appname_releasenumber_date.tar.gz   Maybe there's an easy soluction to do this, but I cannot figure out how to do this.   I've found this solution  but I need to generate some files first in order to keep the number of files I want to.
10703
I have a logfile with timestamps in it. Occasionally there are multiple timestamps in one line. Now I would like to remove all of the timestamps from a line but keep the first one.  I can do s/pattern//2 but that only removes the second occurrence and sed doesn't allow something like s/pattern//2-.  Any suggestions?
3666
Have you ever seen wrong order in /var/log/syslog ? I think that it causes only crontab.  Jun 28 22:20:01 alex CRON[2327]: (root) CMD (something &gt; /dev/null) Jun 28 22:21:01 alex CRON[2700]: (root) CMD (something &gt; /dev/null) Jun 21 03:49:01 alex CRON[2753]: (root) CMD (something &gt; /dev/null) Jun 28 22:23:01 alex CRON[2754]: (root) CMD (something &gt; /dev/null) Jun 27 05:08:01 alex CRON[2813]: (root) CMD (something &gt; /dev/null) Jun 26 00:19:01 alex CRON[2816]: (root) CMD (something &gt; /dev/null) Jun 28 22:25:01 alex CRON[2816]: (munin) CMD (if [ -x /usr/bin/munin-cron ]; then /usr/bin/munin-cron; fi) Jun 28 22:25:01 alex CRON[2821]: (root) CMD (something &gt; /dev/null) Jun 28 22:27:01 alex CRON[3225]: (root) CMD (something &gt; /dev/null) Jun 28 22:28:01 alex CRON[3240]: (root) CMD (something &gt; /dev/null) Jun 28 22:30:01 alex CRON[3290]: (root) CMD (something &gt; /dev/null) Jun 26 12:03:01 alex CRON[3291]: message repeated 2 times: [ (root) CMD (something &gt; /dev/null)] Jun 28 22:30:01 alex CRON[3291]: (munin) CMD (if [ -x /usr/bin/munin-cron ]; then /usr/bin/munin-cron; fi) Jun 28 22:31:01 alex CRON[3659]: (root) CMD (something &gt; /dev/null) Jun 28 22:32:01 alex CRON[3754]: (root) CMD (something &gt; /dev/null) Jun 16 06:41:01 alex CRON[3846]: (root) CMD (something &gt; /dev/null) Jun 28 22:35:58 alex cron[909]: (CRON) INFO (pidfile fd = 3) Jun 28 22:35:58 alex cron[944]: (CRON) STARTUP (fork ok) Jun 28 22:35:58 alex cron[944]: (CRON) INFO (Running @reboot jobs) Jun 28 22:36:01 alex CRON[1428]: (root) CMD (something &gt; /dev/null) Jun 28 22:37:01 alex CRON[3050]: (root) CMD (something &gt; /dev/null) Jun 28 22:38:01 alex CRON[3082]: (root) CMD (something &gt; /dev/null) Jun 28 22:39:01 alex CRON[3114]: (root) CMD (something &gt; /dev/null)   As you can see, there is bad time order between lines. It is just crontab error, or there is some problem with system clock, or something?  I am running the latest Ubuntu 14.04 kernel:  Linux alex 3.13.0-30-generic #54-Ubuntu SMP Mon Jun 9 22:45:01 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
19612
This is probably something basic but I'm not able to make it work. I'm trying to use DU to get a total size of files minus certain directories. I need to exclude one specific directory called uploads but not every directory called uploads. For example, my file structure looks a bit like this:  /store   /uploads     /junk_to_ignore     /more_junk_to_ignore   /user_one     /uploads   /user_two   I can run the following command:   du -ch --exclude=uploads*    and it gives me the file size minus all the "uploads" directories. However, in trying to exclude certain directories (and all its sub-directories) I fail. I've tried variations of:  du -ch --exclude=./uploads* du -ch --exclude='/full/path/to/uploads/*'   but can't seem to figure it out. How do I exclude a specific directory?
72157
I need to print the directory structure of our production system and I would like to remove some specific directories from the ?  How do we specify multiple ignore patterns for tree command?
64213
Does there exist a magical shell piping which would allow easily to grep through bunch of .gz log files without needing to extract them somewhere?  .gz files are Apache logs, result of log rotation. I'd like to quickly check how often certain URIs are accessed in the past.
31301
I have some files and each files have distinct name but all of them have the same "-statement" at the end like this:  flower-statement.mp3 leave-statement.mp3  ball-statement.mp3 goal-statement.mp3   So I want to remove this: -statement  Is that possible?