Article 54Z56 [SOLVED] Deleting directories except last two

[SOLVED] Deleting directories except last two

by
chrisguk
from LinuxQuestions.org on (#54Z56)
I am trying to delete the directories inside another directory with the following command but for me on Debian 10 its not working:

Code:ls -ltr $APPVER | awk -vvar=echo $APPVER/ '/^d/ {A++;X[++j]=$NF} END{for(i=1;i<=A-5;i++){print "rm -rf " var X[i]}}' | shI get this result:

Code:sh: 1: 34mAPP-2.15/: not foundAPP-2.15 being the directory name.

Can anyone assist?latest?d=yIl2AUoC8zA latest?i=ZBPxklwevoM:5tPR6RF9hEA:F7zBnMy latest?i=ZBPxklwevoM:5tPR6RF9hEA:V_sGLiP latest?d=qj6IDK7rITs latest?i=ZBPxklwevoM:5tPR6RF9hEA:gIN9vFwZBPxklwevoM
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments