How do I delete some specified month date and specified file?

How do I delete some specified month date and specified file?

Post by cho shi hyu » Tue, 13 Aug 2002 18:17:58



-rw-r--r--    1 root     root            0 Jul 11 12:12 1.txt
-rw-r--r--    1 root     root            0 Aug 12 11:37 2.txt
-rw-r--r--    1 root     root            0 Aug 12 11:37 3.txt
-rw-r--r--    1 root     root            0 Aug 12 11:38 4.txt
-rw-r--r--    1 root     root            0 Aug 12 11:38 5.txt
-rw-r--r--    1 root     root            0 Aug 12 11:38 6.html

I want to delete *.txt and not create Aug.
# ls -al | egrep -v Aug | egrep .txt
-rw-r--r--    1 root     root            0 Jul 11 12:12 1.txt

But How do I delete use "rm" command?

P.S I know this know-how
# ls -al | egrep -v Aug | egrep .txt | awk '{ print $8}' >  aaa.txt
   and included rm -f in aaa.txt

 
 
 

How do I delete some specified month date and specified file?

Post by Adam Pric » Tue, 13 Aug 2002 19:22:38



> -rw-r--r--    1 root     root            0 Jul 11 12:12 1.txt
> -rw-r--r--    1 root     root            0 Aug 12 11:37 2.txt
> -rw-r--r--    1 root     root            0 Aug 12 11:37 3.txt
> -rw-r--r--    1 root     root            0 Aug 12 11:38 4.txt
> -rw-r--r--    1 root     root            0 Aug 12 11:38 5.txt
> -rw-r--r--    1 root     root            0 Aug 12 11:38 6.html

> I want to delete *.txt and not create Aug.
> # ls -al | egrep -v Aug | egrep .txt
> -rw-r--r--    1 root     root            0 Jul 11 12:12 1.txt

> But How do I delete use "rm" command?

> P.S I know this know-how
> # ls -al | egrep -v Aug | egrep .txt | awk '{ print $8}' >  aaa.txt
>    and included rm -f in aaa.txt

I'm having trouble understanding exactly what you want, but assuming
that the command in your PS, gives the list of files you want removed
in aaa.txt then you can always do...

rm -f `ls -al | egrep -v Aug | egrep .txt | awk '{ print $8}' `

but this could be optimised quite a bit...

rm -f `ls -al *.txt | awk '/Aug/{print $8}'`

Creation date is not stored on a unix system, ls -l displays the time of
last modification.

find can be used to find files with an mtime in the last 'x' days and can
also be used to find file 'not' modified in the last 'x' days.

As an alternative to this you can also find things newer than a particular
file or older than a particular file using the -newer argument.

Hope this helps some,
Adam

 
 
 

How do I delete some specified month date and specified file?

Post by William Par » Wed, 14 Aug 2002 03:33:17



Quote:> -rw-r--r--    1 root     root            0 Jul 11 12:12 1.txt
> -rw-r--r--    1 root     root            0 Aug 12 11:37 2.txt
> -rw-r--r--    1 root     root            0 Aug 12 11:37 3.txt
> -rw-r--r--    1 root     root            0 Aug 12 11:38 4.txt
> -rw-r--r--    1 root     root            0 Aug 12 11:38 5.txt
> -rw-r--r--    1 root     root            0 Aug 12 11:38 6.html

> I want to delete *.txt and not create Aug.
> # ls -al | egrep -v Aug | egrep .txt
> -rw-r--r--    1 root     root            0 Jul 11 12:12 1.txt

> But How do I delete use "rm" command?

> P.S I know this know-how
> # ls -al | egrep -v Aug | egrep .txt | awk '{ print $8}' >  aaa.txt
>   and included rm -f in aaa.txt

1.  ls -l *.txt | awk '/Aug/' {print $9} | xargs rm

2.  ls -l *.txt | awk '/Aug/' {print $9} | while read i; do
        rm $i
    done

3.  rm `ls -l *.txt | awk '/Aug/' {print $9}`

4.  find -maxdepth -daystart -mtime +12 -name '*.txt' | xargs rm

--

8-CPU Cluster, Hosting, NAS, Linux, LaTeX, python, vim, mutt, tin

 
 
 

How do I delete some specified month date and specified file?

Post by cho shihyu » Wed, 14 Aug 2002 09:32:14


Thank you for your help.
But  this command have error on my linux&Aix machine.
1. ls -l *.txt | awk '/Aug/' {print $9} | xargs rm
awk: Cannot find or open file {print.

 The source line number is 1.

3.  rm `ls -l *.txt | awk '/Aug/' {print $9}`
awk: Cannot find or open file {print.

 The source line number is 1.
Usage: rm [-firRe] [--] File ...



> > -rw-r--r--    1 root     root            0 Jul 11 12:12 1.txt
> > -rw-r--r--    1 root     root            0 Aug 12 11:37 2.txt
> > -rw-r--r--    1 root     root            0 Aug 12 11:37 3.txt
> > -rw-r--r--    1 root     root            0 Aug 12 11:38 4.txt
> > -rw-r--r--    1 root     root            0 Aug 12 11:38 5.txt
> > -rw-r--r--    1 root     root            0 Aug 12 11:38 6.html

> > I want to delete *.txt and not create Aug.
> > # ls -al | egrep -v Aug | egrep .txt
> > -rw-r--r--    1 root     root            0 Jul 11 12:12 1.txt

> > But How do I delete use "rm" command?

> > P.S I know this know-how
> > # ls -al | egrep -v Aug | egrep .txt | awk '{ print $8}' >  aaa.txt
> >   and included rm -f in aaa.txt

> 1.  ls -l *.txt | awk '/Aug/' {print $9} | xargs rm

> 2.  ls -l *.txt | awk '/Aug/' {print $9} | while read i; do
> rm $i
>     done

> 3.  rm `ls -l *.txt | awk '/Aug/' {print $9}`

> 4.  find -maxdepth -daystart -mtime +12 -name '*.txt' | xargs rm

> --

> 8-CPU Cluster, Hosting, NAS, Linux, LaTeX, python, vim, mutt, tin

 
 
 

How do I delete some specified month date and specified file?

Post by Chris F.A. Johnso » Wed, 14 Aug 2002 09:41:03



> Thank you for your help.

        Please don't top post.

Quote:> But  this command have error on my linux&Aix machine.
> 1. ls -l *.txt | awk '/Aug/' {print $9} | xargs rm
> awk: Cannot find or open file {print.

>  The source line number is 1.

> 3.  rm `ls -l *.txt | awk '/Aug/' {print $9}`
> awk: Cannot find or open file {print.

       awk  '/Aug/ {print $9}'`

--
    Chris F.A. Johnson                        http://cfaj.freeshell.org
    ===================================================================
    My code (if any) in this post is copyright 2002, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License

 
 
 

How do I delete some specified month date and specified file?

Post by William Par » Wed, 14 Aug 2002 12:24:39




>> Thank you for your help.

>        Please don't top post.

>> But  this command have error on my linux&Aix machine.
>> 1. ls -l *.txt | awk '/Aug/' {print $9} | xargs rm
>> awk: Cannot find or open file {print.

>>  The source line number is 1.

>> 3.  rm `ls -l *.txt | awk '/Aug/' {print $9}`
>> awk: Cannot find or open file {print.

>       awk  '/Aug/ {print $9}'`

As always, Chris is right.  I made typos.  It should've been
    '/Aug/ {print $9}'
not
    '/Aug/' ...

--

8-CPU Cluster, Hosting, NAS, Linux, LaTeX, python, vim, mutt, tin

 
 
 

1. the specified scripts was not running at specified time in crontab

sir,

 I am using RedHat 6.2 Linux
 Again problem with the cron.please sir I am helpless .

 I have written a script and the script contain certain lines.
I want these script to be run on specified time in the script
 I also included the starting line of script as #!/bin/sh

I tried /etc/crontab

 I wrote these lines

30 12 * * * root exec /root/lock daily
32 12 * * * root exec /root/release daily

where lock & release are the script files and they are to be run on
specified time .
but it did not worked

again I tried

30 12 * * *  exec /root/lock daily
32 12 * * *  exec /root/release daily

It did n't worked

again I tried

30 12 * * *  exec /root/lock
32 12 * * *  exec /root/release

it didn't worked

so I tried

30 12 * * *  sh /root/lock
32 12 * * *  sh /root/release

this time  a strange thing happened

that is /root/lock worked at the specified time but /root/release was
not executed .
Why please help .

on typing mail I am getting
just the first task finished and no information was given about the
second task

even I tried

30 12 * * * exec sh /root/lock
32 12 * * * exec  sh /root/release

strange thing happened

that is /root/lock worked at the specified time but /root/release was
not executed .
Why please help .

on typing mail I am getting
just the first task finished and no information was given about the
second task

everytime I am typing

       crontab /etc/crontab
       crontab -l

well it lists out the both tasks to be performed but only first task
was executed but the second task was not executed.

Please help me to run my own tasks at a specified time .HELP me

Pkease help me

2. Apache on Linux 1.2.13 - Does it work?

3. Identifying files older than a specified date

4. Please Help

5. listing names of files modified on after on a specified date/time

6. kernel recompile and Mandrake 7.2

7. Listing files bet. two specified dates

8. Sendmail & NIS+ Nologin Server

9. find files last modified on specified date

10. Newbie Q: Copy files later than specified date

11. crontab, specify last day of month?

12. how to specify last day of month?

13. How do you specify the expiration date on /tmp?