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
replace a character with another character satish@123 Shell Programming and Scripting 8 05-13-2009 04:04 PM
read in a file character by character - replace any unknown ASCII characters with spa raghav525 Shell Programming and Scripting 1 04-20-2009 02:52 PM
character replace pradeep_script Shell Programming and Scripting 3 01-10-2009 05:12 AM
How to Replace,Sort,and Append Character one script ashikin_8119 UNIX for Dummies Questions & Answers 2 11-21-2007 09:53 PM
Command to replace character HLee1981 UNIX for Dummies Questions & Answers 5 10-17-2005 02:27 AM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 07-16-2009
justbow justbow is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 40
Question script command to replace character

Hi,

i have log like this :
Quote:
00:00 ,30011 ,376 ,375
00:00 ,30012 ,474 ,473
01:00 ,30011 ,263 ,262
01:00 ,30012 ,360 ,358
02:00 ,30011 ,416 ,414
02:00 ,30012 ,510 ,508
03:00 ,30011 ,418 ,418
03:00 ,30012 ,459 ,460
04:00 ,30011 ,399 ,397
04:00 ,30012 ,397 ,397
05:00 ,30011 ,498 ,498
05:00 ,30012 ,462 ,461
06:00 ,30011 ,482 ,480
06:00 ,30012 ,403 ,403
07:00 ,30011 ,520 ,515
07:00 ,30012 ,402 ,402
08:00 ,30011 ,539 ,538
08:00 ,30012 ,523 ,523
09:00 ,30011 ,543 ,544
09:00 ,30012 ,557 ,556
10:00 ,30011 ,578 ,576
10:00 ,30012 ,596 ,596
11:00 ,30011 ,651 ,648
11:00 ,30012 ,655 ,651
12:00 ,30011 ,598 ,594
12:00 ,30012 ,535 ,536
13:00 ,30011 ,472 ,472
13:00 ,30012 ,661 ,661
14:00 ,30011 ,457 ,450
14:00 ,30012 ,746 ,729
15:00 ,30011 ,220 ,220
15:00 ,30012 ,672 ,666
16:00 ,30011 ,181 ,181
16:00 ,30012 ,523 ,523
17:00 ,30011 ,174 ,174
17:00 ,30012 ,449 ,449
18:00 ,30011 ,159 ,159
18:00 ,30012 ,355 ,355
19:00 ,30011 ,155 ,154
19:00 ,30012 ,311 ,311
20:00 ,30011 ,150 ,150
20:00 ,30012 ,316 ,316
21:00 ,30011 ,183 ,182
21:00 ,30012 ,316 ,316
22:00 ,30011 ,192 ,193
22:00 ,30012 ,326 ,327
23:00 ,30011 ,190 ,190
23:00 ,30012 ,443 ,443
Actually i want to change the time stamp, and the rule is like this :

Quote:
00:00 --> 08:00
01:00 --> 09:00
02:00 --> 10:00
03:00 --> 11:00
04:00 --> 12:00
05:00 --> 13:00
06:00 --> 14:00
07:00 --> 15:00
08:00 --> 16:00
09:00 --> 17:00
10:00 --> 18:00
11:00 --> 19:00
12:00 --> 20:00
13:00 --> 21:00
14:00 --> 22:00
15:00 --> 23:00
16:00 --> 00:00
17:00 --> 01:00
18:00 --> 02:00
19:00 --> 03:00
20:00 --> 04:00
21:00 --> 05:00
22:00 --> 06:00
23:00 --> 07:00
and My script is like this :

Quote:
cat $@ | sed '
s/00:00/08:00/g;
s/01:00/09:00/g;
s/02:00/10:00/g;
s/03:00/11:00/g;
s/04:00/12:00/g;
s/05:00/13:00/g;
s/06:00/14:00/g;
s/07:00/15:00/g;
s/08:00/16:00/g;
s/09:00/17:00/g;
s/10:00/18:00/g;
s/11:00/19:00/g;
s/12:00/20:00/g;
s/13:00/21:00/g;
s/14:00/22:00/g;
s/15:00/23:00/g;
s/16:00/00:00/g;
s/17:00/01:00/g;
s/18:00/02:00/g;
s/19:00/03:00/g;
s/20:00/04:00/g;
s/21:00/05:00/g;
s/22:00/06:00/g;
s/23:00/07:00/g'
I know the script will loop and loop again after 07:00
like this:
Quote:
00:00 ,30011 ,376 ,375
00:00 ,30012 ,474 ,473
01:00 ,30011 ,263 ,262
01:00 ,30012 ,360 ,358
02:00 ,30011 ,416 ,414
02:00 ,30012 ,510 ,508
03:00 ,30011 ,418 ,418
03:00 ,30012 ,459 ,460
04:00 ,30011 ,399 ,397
04:00 ,30012 ,397 ,397
05:00 ,30011 ,498 ,498
05:00 ,30012 ,462 ,461
06:00 ,30011 ,482 ,480
06:00 ,30012 ,403 ,403
07:00 ,30011 ,520 ,515
07:00 ,30012 ,402 ,402
00:00 ,30011 ,539 ,538
00:00 ,30012 ,523 ,523
01:00 ,30011 ,543 ,544
01:00 ,30012 ,557 ,556
02:00 ,30011 ,578 ,576
02:00 ,30012 ,596 ,596
03:00 ,30011 ,651 ,648
03:00 ,30012 ,655 ,651
04:00 ,30011 ,598 ,594
04:00 ,30012 ,535 ,536
05:00 ,30011 ,472 ,472
05:00 ,30012 ,661 ,661
06:00 ,30011 ,457 ,450
06:00 ,30012 ,746 ,729
07:00 ,30011 ,220 ,220
07:00 ,30012 ,672 ,666
00:00 ,30011 ,181 ,181
00:00 ,30012 ,523 ,523
01:00 ,30011 ,174 ,174
01:00 ,30012 ,449 ,449
02:00 ,30011 ,159 ,159
02:00 ,30012 ,355 ,355
03:00 ,30011 ,155 ,154
03:00 ,30012 ,311 ,311
04:00 ,30011 ,150 ,150
04:00 ,30012 ,316 ,316
05:00 ,30011 ,183 ,182
05:00 ,30012 ,316 ,316
06:00 ,30011 ,192 ,193
06:00 ,30012 ,326 ,327
07:00 ,30011 ,190 ,190
07:00 ,30012 ,443 ,443
Can somebody help me ??

Thanks in advance..
 

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 09:17 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