[solved] Awk/shell question to parse hour minute from text


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [solved] Awk/shell question to parse hour minute from text
# 1  
Old 03-12-2014
[solved] Awk/shell question to parse hour minute from text

Hi,
I have a quick question on parsing the hour/minute and value from a text file and remove the seconds portion. For example in the below text file:
Code:
20:26:01 95.83
20:27:01 96.06
20:28:01 95.99
20:29:01 7.11
20:30:01 5.16
20:31:01 8.27
20:32:02 9.79
20:33:01 11.27
20:34:01 7.83
20:35:01 7.40
20:36:01 9.02
20:37:01 94.72
20:38:01 95.52

I would like the same output but without the seconds part. So,
Code:
20:26 95.83
20:27 96.06
20:28 95.99
20:29 7.11
.... and so on

Thanks so much!

Last edited by vbe; 03-12-2014 at 11:54 AM.. Reason: Please use [code][/code] tags.
# 2  
Old 03-12-2014
Code:
awk '{sub(/:[0-9]* /,FS)}1' file

Code:
sed 's#:[0-9]* # #' file

This User Gave Thanks to Yoda For This Post:
# 3  
Old 03-12-2014
Thanks!! Really have to be better at working with sed and awk.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to parse file and display result based on text

I am trying using awk to open an input file and check a column 2/field $2 and if there is a warning then that is displayed (variantchecker): G not found at position 459, found A instead. The attached Sample1.txt is that file. If in that column/field there is a black space, then the text after... (6 Replies)
Discussion started by: cmccabe
6 Replies

2. Emergency UNIX and Linux Support

[Solved] EMERGENCY - can I revert 1 hour of mysql changes

I know, its stupid.. MYSQL on CENTOS 5 using WHM Imported a lot of users/posts from old forum to new forum, but my backup was lost. Can I somehow simply remove all mysql table changes for the last 3 hours, returning to pre-import status. ---------- Post updated at 03:44 AM ----------... (6 Replies)
Discussion started by: lawstudent
6 Replies

3. Shell Programming and Scripting

Take minute per minute from a log awk

Hi, I've been trying to develop a script that performs the parsing of a log every 1 minute and then generating some statistics. I'm fairly new to programming and this is why I come to ask if I can lend a hand. this is my log: xxxx 16/04/2012 17:00:52 - xxxx714 - E234 - Time= 119 ms.... (8 Replies)
Discussion started by: jockx
8 Replies

4. Emergency UNIX and Linux Support

[Solved] AWK to parse adjacent matching lines

Hi, I have an input file like F : 0.1 : 0.002 P : 0.3 : 0.004 P : 0.5 : 0.008 P : 0.1 : 0.005 L : 0.05 : 0.02 P: 0.1 : 0.006 P : 0.01 : 0.08 F : 0.02 : 0.08 Expected output: (2 Replies)
Discussion started by: vasanth.vadalur
2 Replies

5. UNIX for Dummies Questions & Answers

How to add an hour or a minute to a time?

Hi, The timestamp is June 06 2011 11:05AM i need 2 results. first, an hour added to it, June 06 2011 12:05AM second, a minute added to it, June 06 2011 11:06AM How can i do this? Also when it reaches 12:59, it needs to start from 1 again without giving the output as 13:00. it... (17 Replies)
Discussion started by: irudayaraj
17 Replies

6. Shell Programming and Scripting

counting word xx referred to a time period, like minute or hour

Hello, I try to insert a post because I've got a trouble to perform a unix job. But I didn't found which steps (procedure) I should follow. Could you help me? I got a log by my Application box, like following: gbosmam037:test >view Log_Server.csv ... (2 Replies)
Discussion started by: maluca68
2 Replies

7. Shell Programming and Scripting

sed or awk to parse this text

I am just beginning with sed and awk and understand that they are "per" line input. That is, they operate on each line individually, and output based on rules, etc. But I have multi-line text blocks that looks as follows, and wish to ONLY extract the text between the first hyphen (-) and the... (13 Replies)
Discussion started by: bulgin
13 Replies

8. Shell Programming and Scripting

Parse text file in shell & store to variable

Hi, I need to parse a simple text file like below and store the word that starts with BR* to a variable say $BRno. I need to do this in sh script. NOTE: the length of the numbers following BR is in constant. And there is only 1 BRXXX in a file at a given time. .txt file: BR276828... (1 Reply)
Discussion started by: script2010
1 Replies

9. Shell Programming and Scripting

Crontab for every minute or every hour

How to set crontab for every minute or every hour (1 Reply)
Discussion started by: kaushik02018
1 Replies

10. Shell Programming and Scripting

How to: Parse text string into variables using Korn shell

I am writing a script to keep check on free disk space, and I would like to find a way to parse $LINE (see code below) into a numeric value (for free disk space percentage) and a string value (for mount point). If possible, I would like to avoid sed or any additional use of awk since I am not very... (7 Replies)
Discussion started by: shew01
7 Replies
Login or Register to Ask a Question