string manipulation in der bash

foexle

foexle

Kaiser
Hallo Leute,
ich bekomme per find eine liste von ordnern
alle haben den basis_ordner:

basis_ordner=/var/www/test/

nun gibt es in dem ordner, eine n-tiefe an subfoldern.
also :
/var/www/test/0/11
/var/www/test/0/11/13
/var/www/test/1/14
usw.

ich hätte nun gerne nur den relativen pfad von dem basis-ordner aus ... wie kann ich das realisieren ?

danke
 
Code:
$ echo "/var/www/test/01" | sed 's!/var/www/test/!!g'
01
Sowas in der Art?

mfg
 
Code:
       ${parameter#word}
       ${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.

Code:
$ bla=/var/www/
$ test=/var/www/test/bar
$ echo ${test##"$bla"}
test/bar
 

Ähnliche Themen

E/A-Fehler (.snapshots is not a btrfs subvolume).

3 Wege zur Authentifizierung?

Keine Zugriff von Windows 10 auf Sambafreigaben

Zugriff Ubuntu 16.04. auf Freigabe 18.04. LTS nicht möglich

Prblem mit zeilenweises auslesen von Datei und schreiben nach mysql

Zurück
Oben