Cut command with word as delimiter
I suggest:
awk -F 'ABCD' '{print $1 FS "."}' file
Output:
171212 16082784 6264 XXX xxxxxxxx Transaction XXXXX abend ABCD.
FS
contains your delimiter "ABCD". "ABCD" is a regex.
awk
can do the job if you provide -F
flag with the word which you want to use:
$ awk -F 'test' '{print $1;print $2}' <<< "onetesttwotest"
one
two
In your particular case, that would be:
$ awk -F 'ABCD' '{print $1,FS}' input.txt
171212 16082784 6264 XXX xxxxxxxx Transaction XXXXX abend ABCD
Judging from your example, you're only trying to print stuff up to ABCD
so deleting everything after that is also an option:
$ awk '{print substr($0,0,match($0,/ABCD/)+4);}' input.txt
171212 16082784 6264 XXX xxxxxxxx Transaction XXXXX abend ABCD.
sed
version:
sed 's/ABCD.*/ABCD./' input.txt
171212 16082784 6264 XXX xxxxxxxx Transaction XXXXX abend ABCD.
Source: https://unix.stackexchange.com/questions/257514/how-to-delete-everything-after-a-certain-pattern-or-a-string-in-a-file