Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 17th October 2010, 10:41
apenkov apenkov is offline
Junior Member
 
Join Date: Oct 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Question Shell script to write in a file

Hi,
Can you please help me....I have that command
awk '/Event/{cnt++}END{print cnt,"MBLR", $YESTERDAY}' ME_MBLR_$YESTERDAY* > counter.txt
that writes in counter.txt and the result is:
1234 MBLR
how can I add one more column with the yesterday date? And result to be:
1234 MOBILEROAM 20101016

where $YESTERDAY=20101016

Thanks in advance!!

Atanas
Reply With Quote
Sponsored Links
  #2  
Old 17th October 2010, 19:56
vikas027 vikas027 is offline
Junior Member
 
Join Date: Oct 2010
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb Solved

Quote:
Originally Posted by apenkov View Post
Hi,
Can you please help me....I have that command
awk '/Event/{cnt++}END{print cnt,"MBLR", $YESTERDAY}' ME_MBLR_$YESTERDAY* > counter.txt
that writes in counter.txt and the result is:
1234 MBLR
how can I add one more column with the yesterday date? And result to be:
1234 MOBILEROAM 20101016

where $YESTERDAY=20101016

Thanks in advance!!

Atanas

Suppose you below result is in variable ABC.
1234 MBLR

You can modify it as below
Code:
echo $ABC | sed 's/MBLR/MOBILEROAM/' | sed 's/.*/& '`date -dyesterday  | awk '{print $6"-"$2"-"$3}'`'/'
I have tested this in RHEL machine.

Also, always use commands, scripts, e.t.c in CODE Tags while posting.
__________________
==> VIKAS <==

LINUX SYSTEM ADMINISTRATOR


__________________________________________________

* RHCE - 805009991336981
* Registered Linux User - 484205
* Sun Certified System Administrator for Solaris 10 OS
Reply With Quote
  #3  
Old 18th October 2010, 08:14
apenkov apenkov is offline
Junior Member
 
Join Date: Oct 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
 
Default Shell script to write in a file

Thanks a lot!!
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
rkhunter warnings esezako General 7 27th September 2011 07:28
Forbidden 403; Samba access; config of maildeamon fawkes Installation/Configuration 4 14th January 2010 18:16
sarg issue while generating reports for squid mail4vij Server Operation 3 31st December 2009 13:12
add web site serr57 Installation/Configuration 18 13th April 2008 11:40
Chroot SSH + ISPConfig Norman Installation/Configuration 27 26th March 2007 03:40


All times are GMT +2. The time now is 13:35.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.