fgrep to file plus some

Hi,
I know that I can grep desired data to a file but is there a way to add an additional field of data to the output in addition to what is found. I want to add a login id to the data that is found in the grep. Is this even possible? Thanks for your help.
Toni

You can either:

  1. use 'sed' to do the searching and modify a found record/line adding whatever you want.
  2. use 'awk' to do the same as above
  3. pipe the output to 'sed' to modify found records and save to file afterwords.

Posting a sample file and desired output could help as well.

fgrep"${getdate}"${PROCESSOR${LOGINID}/Sum_SCR_Records.${YEAR}.log
> ${results} 2>/dev/null
The above outputs multiple entries for the date desired (same client can have mulitple entries). There are 3 logs for each client. The idea is to consolidate and recap to a report.
The problem is there is no identification to the client so I would like to add the login id.
Thanks.

Sorry, sample below

Log: entries grep by date
Date, Batch, Number of Items, Amount

Result - need to add client

Client, Batch, Number of Items, Amount

You have mis-balanced '{}' combos: I guess the '${PROCESSOR' is missing a trailing '}': '${PROCESSOR}'

How do you derive the client id?

How do you derive 'Client' value?
What happened with the 'Date' column?

Please post a sample data file and a desired output using BB Codes.

Sorry about that - must have happened in my cut and paste of the code.
I know the grep works though. I have all the data consolidated one file (in the script). I am reading (exec) the client directory and searching for the logs for each client.
I did skip the date in the result. - sorry at work and trying to do too many things.
But the end result is the entire record from the log file plus one field (loginid)

thx

could give a sample path to a file you're using:

fgrep"${getdate}"${PROCESSOR}${LOGINID}/Sum_SCR_Records.${YEAR}.log 

is 'PROCESSOR' somehow "separated" from 'LOGINID' in your file path?
How would one derive the value of LOGINID?

how about:

sed "/${getdate}/ s/^/${LOGINID}/" ${PROCESSOR}${LOGINID}/Sum_SCR_Records.${YEAR}.log 

fgrep"${getdate}"${PROCESSOR}${LOGINID}/Sum_SCR_Records.${YEAR}.log

maybe this wil help

fgrep 02242009 /u/customer/ski/Sum_SCR_Records.2009.log

PROCESSOR is passed here from another script which is always the location of the directory.
LOGIN is coming from the file that is read in this particular script trying to get the data.
The logs do not contain the login but I need to add it to the output.

Sorry to be so confusing.

try the posted 'sed'

thank you , I'm working on it but I have a bad substitution going on. Do I still output to a new file because I do not want to replace what is in the original file.

yes, redirect the output of 'sed' to a new file in the usual manner.

Hi vgersh99,

I still need you. My problem is the date in the log file is formatted as such: 02/25/2009 so I think the sed command is confused. It says
sed: Unrecognized command: /02/25/2009/
Thanks,
Toni

sed "/${getdate}/ s#^#${LOGINID}#" ${PROCESSOR}${LOGINID}/Sum_SCR_Records.${YEAR}.log

Thanks for your help vgersh99!!