create a shell script

create a shell script that process a file

file contain

f2f_100.txt 1234 kkk 12345
f2f_101.txt 1234 mmm 11111
retire_200.txt 2222 rrr 22222
retire_201.txt 1112 qqr 12122

output needed

if first field is f2f then new file fb_$1 contain $2|$4
example filename should be fb_f2f_100.txt and it contains 1234|12345

if first field id retire then new file retire_fb contain $2|$4
example filename should be retire_fb_200.txt and it contains 1112|12122

once again, PLS explain what part of this you're having problems with.
Also, pls read rules prior to posting any further.

Try this code:

#!/usr/bin/ksh
while read f1 f2 f3 f4; do
        case $f1 in
                f2f*) echo "$f2 | $f4" >> fb_$f1;;
                retire*) fname=$(echo $f1 | sed 's/_/_fb_/'); echo "$f2 | $f4" >> $fname;;
                *) echo Boo! This is not supported!
        esac
done < $1

Give the file that contains the records as argument to the script. Note that no error checking / input validation is carried out.

awk :

awk '{print $2" "$4 > "fb_"$1}' filename