Changes between Version 1 and Version 2 of Linux/Shell/ReverseOrderOfList


Ignore:
Timestamp:
29/07/08 18:29:18 (9 years ago)
Author:
tj
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Linux/Shell/ReverseOrderOfList

    v1 v2  
    1414The way to invert the list is: 
    1515{{{ 
    16 $ patches=($(grep -v '^#' debian/patches/series)); for patch in $(seq $((${#patches[@]} - 1)) -1 0); do echo "Reversing ${patches[$patch]}"; patch -R -p1 <debian/patches/${patches[$patch]}; done 
     16$ patches=($(grep -v '^#' debian/patches/series)); for patch in $(seq $((${#patches[@]} - 1)) -1 0); \ 
     17  do echo "Reversing ${patches[$patch]}"; patch -R -p1 <debian/patches/${patches[$patch]}; done 
    1718}}} 
    1819Note the use of `seq [first] [increment] [last]`. In this case `first` is the number of elements in the array, `increment` is -1, and `last` is 0.