Search code examples
linuxbashunixshcd

Change directory to last match in *nix cd command


./
  folder_1
  folder_2
  folder_3
  ...
  folder_46

For first match -> cd folder_* -> folder_1

But what to do for last match (folder_46)


Solution

  • Try this:

    cd `ls -rd folder_*`
    

    There is always a shorter code :)