Getting a string without fixed delimiters

I have a line of text for example

aaaa bbbb cccc dddd eeee ffffff

I would need to get the cccc however bbbb could be there or not.
So whether bbbb is in the line or not I need cccc.

I was looking at either awk or sed....and trying to start at c and end until the next space.

Also the fields are not all spaced out as example..It varies.

awk '{print ($2=="bbbb")?$3:$2}' file

What does "Also the fields are not all spaced out as example..It varies." mean, exactly? There may or may not be spaces, or more that one space, or "cccc" might be somewhere else on the line, or?

Could you show a sample of your actual input data? Anything I write isn't likely to work since I don't know what "ccccccc" is, plus depending on what it is, that may make it very easy or very hard.

The actual output is

16351711 Duplication Done 84 SLP_tor-yd-file-resources-monthly-backup 04/20/11 00:57:48 100 001:13:05 001:13:08 04/20/11 02:10:56

I need what starts with SLP until backup....but the 84 could or could not be there

Yes... But will it always begin with SLP? We need some way to tell the output you want from the output you don't!

If it does, it could be as simple as egrep -o "SLP_[^ \t]+" filename

Yes always SLP
egrep does not work

In what way does egrep "not work"? Nondescriptive answers like that help nobody.

Try it without the \t.

If you don't have the -o option at all on your system, try:

nawk '{ for (N=2; N<=NF; N++) { if($N ~ /^SLP_/) { print $N ; break; } } }' filename

works great thanks. And yes the system has egrep -o but I get nothing returned
awk works

Try the grep without the \t, I think that was fouling it up.

Yet another way of doing it with awk if the needed string always starts with SLP...

echo "16351711 Duplication Done 84 SLP_tor-yd-file-resources-monthly-backup 04/20/11 00:57:48 100 001:13:05 001:13:08 04/20/11 02:10:56" | \
awk -F"SLP" '{print FS$2}'

This may be suffice:

grep ' SLP_*' file
#!/bin/bash
# tested on bash 4

while read -r -a array
do
    for x in "${array[@]}"
    do
        case "$x" in
            SLP_*) echo $x
        esac
    done
done < file