PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > input rm
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

input rm

Réponse
 
LinkBack Outils de la discussion
Vieux 01/08/2007, 09h43   #1
Patrick
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut input rm

Hi,
how can i to give input to rm command ?
i would to delete all file of June. to get June file i write:
ls -al | grep Jul | awk '{ print $9 }'
but now i don't know how redirect this file list to rm command. thanks

  Réponse avec citation
Vieux 01/08/2007, 12h30   #2
Kenny McCormack
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: input rm

In article <1185957832.034263.164380@19g2000hsx.googlegroups. com>,
Patrick <patrick.moresi@gmail.com> wrote:
>Hi,
>how can i to give input to rm command ?
>i would to delete all file of June. to get June file i write:


June?

>ls -al | grep Jul | awk '{ print $9 }'


Or July??

>but now i don't know how redirect this file list to rm command. thanks


ls -al | awk '/Jul/{ print "rm",$9 }' > /tmp/somefile

Next (and this step is very important), check over /tmp/somefile in your
editor and make sure it is right. When you are sure, then do:

sh /tmp/somefile

  Réponse avec citation
Vieux 01/08/2007, 12h56   #3
Janis
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: input rm

On 1 Aug., 13:30, gaze...@xmission.xmission.com (Kenny McCormack)
wrote:
> In article <1185957832.034263.164...@19g2000hsx.googlegroups. com>,
>
> Patrick <patrick.mor...@gmail.com> wrote:
> >Hi,
> >how can i to give input to rm command ?
> >i would to delete all file of June. to get June file i write:

>
> June?
>
> >ls -al | grep Jul | awk '{ print $9 }'

>
> Or July??
>
> >but now i don't know how redirect this file list to rm command. thanks

>
> ls -al | awk '/Jul/{ print "rm",$9 }' > /tmp/somefile
>
> Next (and this step is very important), check over /tmp/somefile in your
> editor and make sure it is right.


And if you have spaces in your filenames quote those names.
(Or let the awk program print some quotes around $9.)

Janis

> When you are sure, then do:
>
> sh /tmp/somefile



  Réponse avec citation
Vieux 01/08/2007, 12h56   #4
Janis
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: input rm

On 1 Aug., 13:30, gaze...@xmission.xmission.com (Kenny McCormack)
wrote:
> In article <1185957832.034263.164...@19g2000hsx.googlegroups. com>,
>
> Patrick <patrick.mor...@gmail.com> wrote:
> >Hi,
> >how can i to give input to rm command ?
> >i would to delete all file of June. to get June file i write:

>
> June?
>
> >ls -al | grep Jul | awk '{ print $9 }'

>
> Or July??
>
> >but now i don't know how redirect this file list to rm command. thanks

>
> ls -al | awk '/Jul/{ print "rm",$9 }' > /tmp/somefile
>
> Next (and this step is very important), check over /tmp/somefile in your
> editor and make sure it is right.


And if you have spaces in your filenames quote those names.
(Or let the awk program print some quotes around $9.)

Janis

> When you are sure, then do:
>
> sh /tmp/somefile



  Réponse avec citation
Vieux 01/08/2007, 13h07   #5
Kenny McCormack
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: input rm

In article <1185969399.900623.146700@l70g2000hse.googlegroups .com>,
Janis <janis_papanagnou@hotmail.com> wrote:
....
>> ls -al | awk '/Jul/{ print "rm",$9 }' > /tmp/somefile
>>
>> Next (and this step is very important), check over /tmp/somefile in your
>> editor and make sure it is right.

>
>And if you have spaces in your filenames quote those names.
>(Or let the awk program print some quotes around $9.)


Good point, but note that if the filenames have spaces in them, then $9
isn't going to pick it up anyway. So, you'll have to re-analyze that
part of the problem as well.

  Réponse avec citation
Vieux 01/08/2007, 13h20   #6
Patrick
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: input rm

On 1 Ago, 14:07, gaze...@xmission.xmission.com (Kenny McCormack)
wrote:
> In article <1185969399.900623.146...@l70g2000hse.googlegroups .com>,Janis <janis_papanag...@hotmail.com> wrote:
>
> ...
>
> >> ls -al | awk '/Jul/{ print "rm",$9 }' > /tmp/somefile

>
> >> Next (and this step is very important), check over /tmp/somefile in your
> >> editor and make sure it is right.

>
> >And if you have spaces in your filenames quote those names.
> >(Or let the awk program print some quotes around $9.)

>
> Good point, but note that if the filenames have spaces in them, then $9
> isn't going to pick it up anyway. So, you'll have to re-analyze that
> part of the problem as well.


ok. Thanks to all
Patrick

  Réponse avec citation
Vieux 01/08/2007, 13h20   #7
Patrick
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: input rm

On 1 Ago, 14:07, gaze...@xmission.xmission.com (Kenny McCormack)
wrote:
> In article <1185969399.900623.146...@l70g2000hse.googlegroups .com>,Janis <janis_papanag...@hotmail.com> wrote:
>
> ...
>
> >> ls -al | awk '/Jul/{ print "rm",$9 }' > /tmp/somefile

>
> >> Next (and this step is very important), check over /tmp/somefile in your
> >> editor and make sure it is right.

>
> >And if you have spaces in your filenames quote those names.
> >(Or let the awk program print some quotes around $9.)

>
> Good point, but note that if the filenames have spaces in them, then $9
> isn't going to pick it up anyway. So, you'll have to re-analyze that
> part of the problem as well.


ok. Thanks to all
Patrick

  Réponse avec citation
Vieux 01/08/2007, 13h55   #8
Janis
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: input rm

On 1 Aug., 14:07, gaze...@xmission.xmission.com (Kenny McCormack)
wrote:
> In article <1185969399.900623.146...@l70g2000hse.googlegroups .com>,Janis <janis_papanag...@hotmail.com> wrote:
>
> >> ls -al | awk '/Jul/{ print "rm",$9 }' > /tmp/somefile

>
> >> Next (and this step is very important), check over /tmp/somefile in your
> >> editor and make sure it is right.

>
> >And if you have spaces in your filenames quote those names.
> >(Or let the awk program print some quotes around $9.)

>
> Good point, but note that if the filenames have spaces in them, then $9
> isn't going to pick it up anyway. So, you'll have to re-analyze that
> part of the problem as well.


Indeed, right you are.

Having now a closer look at the OP's task I wonder why there's the -a
option; it would be "tricky" to remove . and .. with a rm command.

And the pattern /Jul/ should be restricted to the respective date
field as to not accidentally remove a file called Julian.txt or any
file that has a user or group field containing "Jul".

And some systems have a different number of fields in the ls command,
depending on whether the file is older than 6 months or not.

....there's still some work to make that command more robust.

Janis

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 19h15.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,19269 seconds with 16 queries