Need to append the date | abcddate.txt to the first line of my txt file

I want to add/append the info in the following format to my.txt file.

20130702|abcd20130702.txt FN|SN|DOB

I tried the below script but it throws me some exceptions.

<#!/bin/sh
dt = date '+%y%m%d'members;
echo $dt+|+members+$dt;
/usr/bin/awk -f
BEGIN { FS="|"; OFS="|"; } { print $1,$2,$5};>

Can some one please heelp me to sort this out.

Thanks,
Harry

Please post a sample of the input and desired output...

the input of the file looks like below and the file type is .txt
first Line in the abcd.txt is as follows

FN|LN|DOB|ADDRESS|ZIP

The out put should be the same abcd.txt file and the first line should looks like below

20130807|abcd20130807.txtFN|LN|DOB|ADDRESS|ZIP

Thanks

#!/bin/bash

v_file="abcd.txt"
v_date="$( date +%Y%m%d )"
v_memb="${v_file%.*}"
v_memb="${v_memb}${v_date}.txt"

while read line
do
        echo "${v_date}|${v_memb}${line}"
done < "$v_file"

Thanks Yoda for your reply,

But some how the script is throwing some exceptions.

I am trying to run this as a AWK script and it throws exceptions.

The file name I am getting is abcd.txt and I need to append the

20130807|abcd20130807.txtFN|LN|DOB|ADDRESS|ZIP 

to the first line.. so I am running a awk script to do this...

I created a awk script like below

#!/usr/bin/awk -f
BEGIN {system("date '+%d%m%Y''|abcd.")system("date '+%d%m%Y'.txt");FS="|"; OFS="|"; } { print $1,$2,$3,$6,$5};

But the out put I am getting like below

07082013|abcd
07082013.txt
FN|LN|DOB|ADDRESS|ZIP

I just want to get this in a single line.

Thanks

Try this:

awk -v DT="$(date +%Y%m%d)" '{print DT,"abcd"DT".txt"$0}' OFS=\| abcd.txt

Output:

20130807|abcd20130807.txtFN|LN|DOB|ADDRESS|ZIP

I tried the code, it works, but it appends the syntax to all the lines. I just want to put this in the very first line.
May be some small changes needs to be done :slight_smile: