sh - How could I remove one older folder with bash? -


i have following folders:

1435773881 jul  1 21:04 1435774663 jul  2 21:17 1435774856 jul  3 21:20 1435775432 jul  4 21:56 

i need remove older folder folder (1435773881 in case above) bash script.

what command should use?

you can do

ls -lt | tail -1 | awk '{print $nf}' | xargs rm -rf 
  • ls -lt | tail -1 shows last line after sorting directories date
  • awk '{print $nf}' "prints" last column (which directory name)
  • xargs rm -rf deletes directory

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -