I have a large number of files in a log-directory, whose names were time-stamped (in this case with date +%b[...]).
I want to write a POSIX compliant one-liner that will:
either
- skip lines output from
ls -ltcthat have 2 fields or less (as seen byawk) and do not contain the regexp constant/Jul/
or
- skip the first line output by
ls -ltcand any line not matching/Jul/.
The result is the same for my purpose as only the first line consists of two fields (as seen by awk).
I tried:
> ll -tc | rm $(awk --posix 'NF > 2 && !/Jul/ {print $NF;}')
> ll -tc | rm $(awk --posix 'NF > 2 !/Jul/ {print $NF;}')
Both have bad syntax because a condition on NF apparently does not coexist nicely with a regexp matching condition the way ls | awk '/foo/ && /bar/'would for instance.
Can sb give me pointers on how to either skip any arbitrary record and/or apply the arithmetic condition on NF and the regexp pattern matching at the same time ? I did look around but could not find the documented syntax I am looking for...