Skip to content
Advertisement

Looping over the last subdirectory to zip in linux terminal

given the following structure:

JavaScript

How do I find & zip the last subdirectory in specific directories?

  1. The directory starts with ‘b’ (ex) ‘b1’, ‘b2’
  2. Find the last subdirectory and zip it (ex) ‘b14’, ‘b22’

I want something like:

JavaScript

The output has to be:

JavaScript

Advertisement

Answer

Pipe to tail -1 to get the last line.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement