The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Parsing a line in Shell Script unishiva Shell Programming and Scripting 3 11-01-2007 04:30 PM
Problem parsing line in file rlwilli Shell Programming and Scripting 2 09-02-2006 12:15 PM
parsing a delimited line monkeys Shell Programming and Scripting 11 07-12-2006 07:24 PM
command line argument parsing rmjoe UNIX for Dummies Questions & Answers 1 07-28-2005 04:39 PM
Parsing the command line arguments jayakhanna UNIX for Advanced & Expert Users 7 12-17-2003 07:42 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-30-2007
xeniya xeniya is offline
Registered User
  
 

Join Date: May 2007
Posts: 3
Smile Parsing line out of a file, please help !!

Hello, I have a file with several lines

for example;

I need to extract a line radiusAuthServTotalAccessRequests.0 = 0
and I don't have line #s in the file.

I need to write a script to extract the above line, put a date beside it and parse this line out to another directory / file.

How can I do this ?

You feedback would be greatly appreciated

Thank you so much to those who already replied and those who will reply.

Last edited by xeniya; 05-30-2007 at 06:10 PM..
  #2 (permalink)  
Old 05-30-2007
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,433
You can do something like that:

Code:
read line < infile # read first line
echo "$(date +'%d/%m/%Y') ${line}" > outfile

With your file example, the outfile is :

Code:
30/05/2007 A

Jean-Pierre.
  #3 (permalink)  
Old 05-30-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
  
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Xeniya,
See if is this what you want.
'input_file' is the file with your lines (A, B, C, etc.)

Code:
while read mEachLine
do
  mNewLine=${mEachLine}"<your_date_here>"
  ### use 'mNewLine' as you wish ###
done < input_file

  #4 (permalink)  
Old 05-30-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,557

Code:
awk '/radiusAuthServTotalAccessRequests/{"date +%Y%m%d"|getline d 
                                         print d" "$0> "outfile"}' "file"

  #5 (permalink)  
Old 05-31-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
  
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Xeniya,
I can see that you changed your original request.
Instead you should issue another post.
It is not fair to the people that offer solutions to change your original
specifications after the solutions have been given.
  #6 (permalink)  
Old 05-31-2007
xeniya xeniya is offline
Registered User
  
 

Join Date: May 2007
Posts: 3
Oh, i am so sorry, I am new to this Forum and don't know all the rules yet. I thought editing the original reply was the thing to do but I guess not. I didn't mean to cause trouble, sorry.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:39 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0