With `zsh` (the only shell that can store arbitrary byte sequences in its variables), assuming `data` and `delimiter` are regular (or at least mmap()able) files, you can do:
```
zmodload zsh/mapfile
firstpart=${mapfile[data]%%$mapfile[delimiter]*}
```
Or:
```
zmodload zsh/mapfile
delimiter=$mapfile[delimiter]
parts=( ${(ps[$delimiter])mapfile[data]} )
firstpart=$parts[1]
```
(don't expect it to be very efficient nor to scale well to files larger than a few hundred megabytes. If in a locale using a multibyte charmap such as UTF-8, disabling the `multibyte` option (`set +o multibyte`) should make it more efficient).
To print that part verbatim, use:
```
print -rn -- $firstpart
```
Or
```
printf %s $firstpart
```