Ices_Eyes ha scritto:fromtheflames ha scritto:e quel ${1##vd:*} fa tutto questo? azz... non immaginavo
In realtà quello elimina solo la parte finale del parametro $1 ecc...Il controllo se è vuoto il risultato lo fa il -z dell'if...
Dal man di bash
${parameter##word}
The word is expanded to produce a pattern just as in pathname
expansion. If the pattern matches the beginning of the value of
parameter, then the result of the expansion is the expanded
value of parameter with the shortest matching pattern (the ``#''
case) or the longest matching pattern (the ``##'' case) deleted.
If parameter is @ or *, the pattern removal operation is applied
to each positional parameter in turn, and the expansion is the
resultant list. If parameter is an array variable subscripted
with @ or *, the pattern removal operation is applied to each
member of the array in turn, and the expansion is the resultant
list.
Tu intendi questo, vero?
Se quel comando rimuove l'occorrenza più lunga della sottostringa (ovvero vd:* - che a me fa venire in mente tutte le stringhe che cominciano con "vd:", il che non so se sia esattamente quello che cerchi), la stringa che ti rimane sarà vuota per ogni nome di file/cartella che comincia con "vd:" es: vd:1, vd:gianna, ecc...
Ices_Eyes ha scritto:Xerex ha scritto:hai necessità di fare tutto nel minor numero di righe possibili senza "appoggiarti", magari, ad un file temporaneo, o puoi "allargarti"?
Lo script dovrà sostituirsi al normale ls di linux (poi dovrò farlo per cp, mkdir, rm...) perché devo poter gestire, nel caso di determinati prefissi, un disco virtuale in modo trasparente all'utente...Quindi il tutto nel minor numero di file possibile...
Se le specifiche ti indicano chiaramente di fare uno script bash è un conto, altrimenti questo sarebbe un lavoro per il C