|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi:
I´m looking for a way to remove all *.trw files in a specified directory, but maintaining the last 15 *.trw files... Thank You for your . |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On 2008-05-02, apogeusistemas@gmail.com <apogeusistemas@gmail.com> wrote:
> > > Hi: > > I´m looking for a way to remove all *.trw files in a specified > directory, but maintaining the last 15 *.trw files... > > Thank You for your . How do you define last? If you mean last modified: ls -t *.trw | tail -n +16 | xargs rm |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On 2008-05-02, apogeusistemas@gmail.com <apogeusistemas@gmail.com> wrote:
> Hi: > > I´m looking for a way to remove all *.trw files in a specified > directory, but maintaining the last 15 *.trw files... How are you defining "last"? Last in alphabetical order? The most recently modified? Some other way? I assume by "maintaining" you mean you want remove all *except* the "last" 15 (whatever "last" means). > > Thank You for your . -- Christopher Mattern NOTICE Thank you for noticing this new notice Your noticing it has been noted And will be reported to the authorities |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On May 2, 5:05pm, Chris Mattern <sys...@sumire.gwu.edu> wrote:
> On 2008-05-02, apogeusiste...@gmail.com <apogeusiste...@gmail.com> wrote: > > > Hi: > > > I´m looking for a way to remove all *.trw files in a specified > > directory, but maintaining the last 15 *.trw files... > > How are you defining "last"? Last in alphabetical order? The most > recently modified? Some other way? > > I assume by "maintaining" you mean you want remove all *except* > the "last" 15 (whatever "last" means). > > > > > Thank You for your . > > -- > Christopher Mattern > > NOTICE > Thank you for noticing this new notice > Your noticing it has been noted > And will be reported to the authorities Last 15 files created... thanks |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
apogeusistemas@gmail.com wrote:
> On May 2, 5:05 pm, Chris Mattern <sys...@sumire.gwu.edu> wrote: >> On 2008-05-02, apogeusiste...@gmail.com <apogeusiste...@gmail.com> wrote: >> >>> I´m looking for a way to remove all *.trw files in a specified >>> directory, but maintaining the last 15 *.trw files... >> How are you defining "last"? Last in alphabetical order? The most >> recently modified? Some other way? >> >> I assume by "maintaining" you mean you want remove all *except* >> the "last" 15 (whatever "last" means). > > Last 15 files created... You can't do that. Unix doesn't store the creation date anywhere. John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order. -- Larry Wall |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
On May 2, 5:27pm, "John W. Krahn" <some...@example.com> wrote:
> apogeusiste...@gmail.com wrote: > > On May 2, 5:05 pm, Chris Mattern <sys...@sumire.gwu.edu> wrote: > >> On 2008-05-02, apogeusiste...@gmail.com <apogeusiste...@gmail.com> wrote: > > >>> I´m looking for a way to remove all *.trw files in a specified > >>> directory, but maintaining the last 15 *.trw files... > >> How are you defining "last"? Last in alphabetical order? The most > >> recently modified? Some other way? > > >> I assume by "maintaining" you mean you want remove all *except* > >> the "last" 15 (whatever "last" means). > > > Last 15 files created... > > You can't do that. Unix doesn't store the creation date anywhere. > > John > -- > Perl isn't a toolbox, but a small machine shop where you > can special-order certain sorts of tools at low cost and > in short order. -- Larry Wall but how could I sort using date and hour ? |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
On 5/2/2008 4:07 PM, apogeusistemas@gmail.com wrote: > On May 2, 5:27 pm, "John W. Krahn" <some...@example.com> wrote: > >>apogeusiste...@gmail.com wrote: >> >>>On May 2, 5:05 pm, Chris Mattern <sys...@sumire.gwu.edu> wrote: >>> >>>>On 2008-05-02, apogeusiste...@gmail.com <apogeusiste...@gmail.com> wrote: >>> >>>>>I´m looking for a way to remove all *.trw files in a specified >>>>>directory, but maintaining the last 15 *.trw files... >>>> >>>>How are you defining "last"? Last in alphabetical order? The most >>>>recently modified? Some other way? >>> >>>>I assume by "maintaining" you mean you want remove all *except* >>>>the "last" 15 (whatever "last" means). >>> >>>Last 15 files created... >> >>You can't do that. Unix doesn't store the creation date anywhere. >> >>John >>-- >>Perl isn't a toolbox, but a small machine shop where you >>can special-order certain sorts of tools at low cost and >>in short order. -- Larry Wall > > > but how could I sort using date and hour ? date and hour of what? You can use last access time or last modification time, you just can't use creation time. Ed. |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
On 2008-05-02, apogeusistemas@gmail.com <apogeusistemas@gmail.com> wrote:
> On May 2, 5:27pm, "John W. Krahn" <some...@example.com> wrote: >> apogeusiste...@gmail.com wrote: >> > On May 2, 5:05 pm, Chris Mattern <sys...@sumire.gwu.edu> wrote: >> >> On 2008-05-02, apogeusiste...@gmail.com <apogeusiste...@gmail.com> wrote: >> >> >>> I´m looking for a way to remove all *.trw files in a specified >> >>> directory, but maintaining the last 15 *.trw files... >> >> How are you defining "last"? Last in alphabetical order? The most >> >> recently modified? Some other way? >> >> >> I assume by "maintaining" you mean you want remove all *except* >> >> the "last" 15 (whatever "last" means). >> >> > Last 15 files created... >> >> You can't do that. Unix doesn't store the creation date anywhere. >> > > but how could I sort using date and hour ? A number of ways. Unix stores mtime (last time the file's data was modified), atime (last time the file's data was read) and ctime (last time the file's inode data was modified; this can changed by changing a file's permissions, ownership or using ln or rm to create or destroy links to the file). Which one do you want to use? -- Christopher Mattern NOTICE Thank you for noticing this new notice Your noticing it has been noted And will be reported to the authorities |
|
|
|
#9 |
|
Messages: n/a
Hébergeur: |
On 2008-05-02, Ed Morton <morton@lsupcaemnt.com> wrote:
> > > On 5/2/2008 4:07 PM, apogeusistemas@gmail.com wrote: >> On May 2, 5:27 pm, "John W. Krahn" <some...@example.com> wrote: >> >>>apogeusiste...@gmail.com wrote: >>> >>>>On May 2, 5:05 pm, Chris Mattern <sys...@sumire.gwu.edu> wrote: >>>> >>>>>On 2008-05-02, apogeusiste...@gmail.com <apogeusiste...@gmail.com> wrote: >>>> >>>>>>I´m looking for a way to remove all *.trw files in a specified >>>>>>directory, but maintaining the last 15 *.trw files... >>>>> >>>>>How are you defining "last"? Last in alphabetical order? The most >>>>>recently modified? Some other way? >>>> >>>>>I assume by "maintaining" you mean you want remove all *except* >>>>>the "last" 15 (whatever "last" means). >>>> >>>>Last 15 files created... >>> >>>You can't do that. Unix doesn't store the creation date anywhere. >>> >> >> >> but how could I sort using date and hour ? > > date and hour of what? You can use last access time or last modification time, > you just can't use creation time. > There's also change time; if they're not changing around permissions or ownerships, or using hard links to the file, it can be used as a proxy for creation time. -- Christopher Mattern NOTICE Thank you for noticing this new notice Your noticing it has been noted And will be reported to the authorities |
|
|
|
#10 |
|
Messages: n/a
Hébergeur: |
On 2 maio, 18:57, Chris Mattern <sys...@sumire.gwu.edu> wrote:
> On 2008-05-02, Ed Morton <mor...@lsupcaemnt.com> wrote: > > > > > > > On 5/2/2008 4:07 PM, apogeusiste...@gmail.com wrote: > >> On May 2, 5:27 pm, "John W. Krahn" <some...@example.com> wrote: > > >>>apogeusiste...@gmail.com wrote: > > >>>>On May 2, 5:05 pm, Chris Mattern <sys...@sumire.gwu.edu> wrote: > > >>>>>On 2008-05-02, apogeusiste...@gmail.com <apogeusiste...@gmail.com> wrote: > > >>>>>>I´m looking for a way to remove all *.trw files in a specified > >>>>>>directory, but maintaining the last 15 *.trw files... > > >>>>>How are you defining "last"? Last in alphabetical order? The most > >>>>>recently modified? Some other way? > > >>>>>I assume by "maintaining" you mean you want remove all *except* > >>>>>the "last" 15 (whatever "last" means). > > >>>>Last 15 files created... > > >>>You can't do that. Unix doesn't store the creation date anywhere. > > >> but how could I sort using date and hour ? > > > date and hour of what? You can use last access time or last modificationtime, > > you just can't use creation time. > > There's also change time; if they're not changing around permissions or > ownerships, or using hard links to the file, it can be used as a proxy > for creation time. > > -- > Christopher Mattern > > NOTICE > Thank you for noticing this new notice > Your noticing it has been noted > And will be reported to the authorities- Ocultar texto entre aspas - > > - Mostrar texto entre aspas - I create this script, but it's removing last modified files, but I want exactly the opposite. ls -ltr *.trw | tail +15 | awk '{ print $9 }' > x.lis for file in `cat x.lis` do ls -l $file #rm $file done issuing ls -ltr I get this -> ls -ltr *.trw -rw-r----- 1 oradm dba 25085423 May 2 09:51 dm581_ora_10744.trw -rw-r----- 1 oradm dba 25085487 May 2 09:51 dm789_ora_10742.trw -rw-r----- 1 oradm dba 790 May 2 10:03 dm532_reco_27372.trw -rw-r----- 1 oradm dba 862 May 2 10:11 dm351_ora_10969.trw -rw-r----- 1 oradm dba 25240999 May 2 10:21 dm676_ora_10881.trw -rw-r----- 1 oradm dba 25240991 May 2 10:21 dm321_ora_10879.trw -rw-rw---- 1 oradm dba 755 May 2 10:37 dm143_ora_3295.trw -rw-rw---- 1 oradm dba 753 May 2 10:37 dm989_ora_3254.trw but I need any ls command to show me this -> -rw-rw---- 1 oradm dba 753 May 2 10:37 dm989_ora_3254.trw -rw-rw---- 1 oradm dba 755 May 2 10:37 dm143_ora_3295.trw -rw-r----- 1 oradm dba 25240991 May 2 10:21 dm321_ora_10879.trw -rw-r----- 1 oradm dba 25240999 May 2 10:21 dm676_ora_10881.trw -rw-r----- 1 oradm dba 862 May 2 10:11 dm351_ora_10969.trw -rw-r----- 1 oradm dba 790 May 2 10:03 dm532_reco_27372.trw -rw-r----- 1 oradm dba 25085487 May 2 09:51 dm789_ora_10742.trw -rw-r----- 1 oradm dba 25085423 May 2 09:51 dm581_ora_10744.trw |
|
|
|
#11 |
|
Messages: n/a
Hébergeur: |
Caution with the alias "ls":
x=1;/bin/ls -1dt *.trw|while read F;do if [ $x -gt 15 ];then echo rm $F else echo ok $F x=$[x+1] fi done apogeusiste...@gmail.com wrote: > On 2 maio, 18:57, Chris Mattern <sys...@sumire.gwu.edu> wrote: > > On 2008-05-02, Ed Morton <mor...@lsupcaemnt.com> wrote: > > > > > > > > > > > > > On 5/2/2008 4:07 PM, apogeusiste...@gmail.com wrote: > > >> On May 2, 5:27 pm, "John W. Krahn" <some...@example.com> wrote: > > > > >>>apogeusiste...@gmail.com wrote: > > > > >>>>On May 2, 5:05 pm, Chris Mattern <sys...@sumire.gwu.edu> wrote: > > > > >>>>>On 2008-05-02, apogeusiste...@gmail.com <apogeusiste...@gmail.com> wrote: > > > > >>>>>>I�m looking for a way to remove all *.trw files in a specified > > >>>>>>directory, but maintaining the last 15 *.trw files... > > > > >>>>>How are you defining "last"? �Last in alphabetical order? �The most > > >>>>>recently modified? �Some other way? > > > > >>>>>I assume by "maintaining" you mean you want remove all *except* > > >>>>>the "last" 15 (whatever "last" means). > > > > >>>>Last 15 files created... > > > > >>>You can't do that. �Unix doesn't store the creation date anywhere. > > > > >> but how could I sort using date and hour ? > > > > > date and hour of what? You can use last access time or last modification time, > > > you just can't use creation time. > > > > There's also change time; if they're not changing around permissions or > > ownerships, or using hard links to the file, it can be used as a proxy > > for creation time. > > > > -- > > � � � � � � �Christopher Mattern > > > > NOTICE > > Thank you for noticing this new notice > > Your noticing it has been noted > > And will be reported to the authorities- Ocultar texto entre aspas - > > > > - Mostrar texto entre aspas - > > I create this script, but it's removing last modified files, but I > want exactly the opposite. > > ls -ltr *.trw | tail +15 | awk '{ print $9 }' > x.lis > for file in `cat x.lis` > do > ls -l $file > #rm $file > done > > > issuing ls -ltr I get this -> > > ls -ltr *.trw > > -rw-r----- 1 oradm dba 25085423 May 2 09:51 > dm581_ora_10744.trw > -rw-r----- 1 oradm dba 25085487 May 2 09:51 > dm789_ora_10742.trw > -rw-r----- 1 oradm dba 790 May 2 10:03 > dm532_reco_27372.trw > -rw-r----- 1 oradm dba 862 May 2 10:11 > dm351_ora_10969.trw > -rw-r----- 1 oradm dba 25240999 May 2 10:21 > dm676_ora_10881.trw > -rw-r----- 1 oradm dba 25240991 May 2 10:21 > dm321_ora_10879.trw > -rw-rw---- 1 oradm dba 755 May 2 10:37 > dm143_ora_3295.trw > -rw-rw---- 1 oradm dba 753 May 2 10:37 > dm989_ora_3254.trw > > but I need any ls command to show me this -> > > -rw-rw---- 1 oradm dba 753 May 2 10:37 > dm989_ora_3254.trw > -rw-rw---- 1 oradm dba 755 May 2 10:37 > dm143_ora_3295.trw > -rw-r----- 1 oradm dba 25240991 May 2 10:21 > dm321_ora_10879.trw > -rw-r----- 1 oradm dba 25240999 May 2 10:21 > dm676_ora_10881.trw > -rw-r----- 1 oradm dba 862 May 2 10:11 > dm351_ora_10969.trw > -rw-r----- 1 oradm dba 790 May 2 10:03 > dm532_reco_27372.trw > -rw-r----- 1 oradm dba 25085487 May 2 09:51 > dm789_ora_10742.trw > -rw-r----- 1 oradm dba 25085423 May 2 09:51 > dm581_ora_10744.trw |
|
|
|
#12 |
|
Messages: n/a
Hébergeur: |
Chris Mattern wrote:
> On 2008-05-02, Ed Morton <morton@lsupcaemnt.com> wrote: >> >> You can use last access time or last modification time, >> you just can't use creation time. >> > There's also change time; if they're not changing around permissions or > ownerships, or using hard links to the file, it can be used as a proxy > for creation time. No it can't. The ctime is also updated when the file is written to. -- Geoff Clare <netnews@gclare.org.uk> |
|
|
|
#13 |
|
Messages: n/a
Hébergeur: |
On Fri, 2 May 2008 15:35:44 -0700 (PDT), apogeusistemas@gmail.com
wrote: <snip> > >I create this script, but it's removing last modified files, but I >want exactly the opposite. > >ls -ltr *.trw | tail +15 | awk '{ print $9 }' > x.lis >for file in `cat x.lis` >do >ls -l $file >#rm $file >done > > >issuing ls -ltr I get this -> > >ls -ltr *.trw > >-rw-r----- 1 oradm dba 25085423 May 2 09:51 >dm581_ora_10744.trw >-rw-r----- 1 oradm dba 25085487 May 2 09:51 >dm789_ora_10742.trw >-rw-r----- 1 oradm dba 790 May 2 10:03 >dm532_reco_27372.trw >-rw-r----- 1 oradm dba 862 May 2 10:11 >dm351_ora_10969.trw >-rw-r----- 1 oradm dba 25240999 May 2 10:21 >dm676_ora_10881.trw >-rw-r----- 1 oradm dba 25240991 May 2 10:21 >dm321_ora_10879.trw >-rw-rw---- 1 oradm dba 755 May 2 10:37 >dm143_ora_3295.trw >-rw-rw---- 1 oradm dba 753 May 2 10:37 >dm989_ora_3254.trw As expected. You told ls to reverse the order when you supplied the -r option... > >but I need any ls command to show me this -> > >-rw-rw---- 1 oradm dba 753 May 2 10:37 >dm989_ora_3254.trw >-rw-rw---- 1 oradm dba 755 May 2 10:37 >dm143_ora_3295.trw >-rw-r----- 1 oradm dba 25240991 May 2 10:21 >dm321_ora_10879.trw >-rw-r----- 1 oradm dba 25240999 May 2 10:21 >dm676_ora_10881.trw >-rw-r----- 1 oradm dba 862 May 2 10:11 >dm351_ora_10969.trw >-rw-r----- 1 oradm dba 790 May 2 10:03 >dm532_reco_27372.trw >-rw-r----- 1 oradm dba 25085487 May 2 09:51 >dm789_ora_10742.trw >-rw-r----- 1 oradm dba 25085423 May 2 09:51 >dm581_ora_10744.trw Then remove the -r option, as in ls -lt Scott McMillan |
|
![]() |
| Outils de la discussion | |
|
|