Search code examples
arraysstringselectionmayamel

How to get all but last item in a MEL array?


I want to get the user selection and assign all but the last object to one array variable and the last selected object to another variable.

how can I do this?

Thank you


Solution

  • $first = `ls -sl -head 1`;
    $last = `ls -sl -tail 1`;
    string $all_except_last[] = stringArrayRemove(`ls -sl -tail 1`, `ls -sl -fl`);
    string $all_except_first[] = stringArrayRemove(`ls -sl -head 1`, `ls -sl -fl`);
    //don't forget to use -fl (flat list) flag