Re: input rm



Daniel Rock wrote:
Patrick <patrick.moresi@xxxxxxxxx> 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:
ls -al | grep Jul | awk '{ print $9 }'


What about filenames which have the string "Jul" somewhere in their name?

Right. He could use:

ls -al | awk '$6 ~ "Jul" { print $9 }'

if the month name is in the 6th field, and in a POSIX awk (i.e. one that
supports Regular Expession Intervals) to select everything from the 9th
field on (to accomodate file names with non-newline spaces) would be:

sub(/^[[:space:]]*([^[:space:]]*[[:space:]]*){8}/,"")

So, with GNU awk you'd use:

ls -al | gawk --re-interval '$6 ~ "Jul" {
sub(/^[[:space:]]*([^[:space:]]*[[:space:]]*){8}/,""); print }'

Regards,

Ed.

.



Relevant Pages

  • Re: input rm
    ... Ed Morton wrote: ... how can i to give input to rm command? ... if the month name is in the 6th field, and in a POSIX awk (i.e. one that ... Michael Tosch @ hp: com ...
    (comp.unix.shell)
  • Re: reassemble command line but exactly keep given words
    ... > Now the problem is to reassemble a command line for jonk. ... set of positional parameters). ... You could also use awk to escape the arguments (POSIX awk ...
    (comp.unix.shell)
  • Re: top command
    ... Daniel Rock wrote: ... on SUN solaris8, there are many users using the system from command ... machine you would need over 100 top processes to hog one CPU. ...
    (comp.unix.solaris)
  • Re: LD_OPTIONS when compile agaist csw and Sun provided libs
    ... Daniel Rock wrote: ... the command line, immediately following the name used to ... does anyone know a trick to get ld not to look in the usual places? ... We've tried various hacks but it still seems to search /usr/lib. ...
    (comp.unix.solaris)