Either
grep -P -o 'Data.+?\d\d\d\d-\d\d-\d\d'
or
perl -pe 's/^.+(Data.+?\d\d\d\d-\d\d-\d\d).+$/$1/'
will do. They both print the minimal string that starts with Data
and ends in what looks like a date (YYYY-MM-DD).
echo "fvvDataFolders/DDB/DDB2018-02-21oM]" > input.txt
echo "fbbDataFolders/DDB/DDB2018-02-22oM]" >> input.txt
grep -P -o 'Data.+?\d\d\d\d-\d\d-\d\d' input.txt
# output:
DataFolders/DDB/DDB2018-02-21
DataFolders/DDB/DDB2018-02-22
perl -pe 's/^.+(Data.+?\d\d\d\d-\d\d-\d\d).+$/$1/' input.txt
# output:
DataFolders/DDB/DDB2018-02-21
DataFolders/DDB/DDB2018-02-22
Data
and ends in what looks like a date? Or just the characters 4-32? That would becut -c 4-32
. – PerlDuck Feb 25 '18 at 12:43