Help me with file conversion [Shell Script]

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help me with file conversion [Shell Script]
# 1  
Old 09-25-2009
Help me with file conversion [Shell Script]

Hello Group,

I request your help with a shell script for filter an ascii file (this is small piece of the file):


The second field above correspond to the hour and I need only the hours between 12:00 and 22:00 and discard the others rows.

I have Ubuntu in my computer

I really appreciate it your help



Last edited by vgersh99; 09-25-2009 at 02:49 PM.. Reason: code tags, PLEASE!
# 2  
Old 09-25-2009
Something like this?

awk -F",|:" '$2 > 11 && $2 < 23' file

This User Gave Thanks to Franklin52 For This Post:
# 3  
Old 09-25-2009
To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags [code] and [/code] by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums
# 4  
Old 09-25-2009
Ad hoc:

#! /bin/bash

cat ascii.file | \
while read LINE
  TIME=$( echo $LINE | awk -F ',' '{ print $2 }' | sed 's/://' )
  if [ $TIME -ge 1200 ] && [ $TIME -le 2200 ]
    echo "$LINE"

exit 0

This User Gave Thanks to For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell script ouput conversion

Hi All, I am trying to print all the packages info in solaris 11 using below script. #!/usr/bin/env bash pkginfo -l | egrep '(BASEDIR|NAME|VERSION)' | awk '{print}' > /tmp/cp1 /usr/bin/nawk -F: ' {for (i=1; i<=NF; i++) {gsub (/^ *| *$/, "", $i) ... (5 Replies)
Discussion started by: sravani25
5 Replies

2. UNIX for Beginners Questions & Answers

powershell script to unix shell script conversion.

Here is a powershell script to use restful API to create ticket in our ticketing tool. Can anyone please convert it to a shell script sothat, I can run it in Unix servers, below is the code: $body = @{ Customer= ''test' Summary= 'test summary' Impact= '4-Minor/Localized' ... (2 Replies)
Discussion started by: pandeybhavesh18
2 Replies

3. Shell Programming and Scripting

Batch to shell script conversion

Hi All, I have a small tool which is currently configured in batch scripts only. But my need is to run it on Linux platform, so I have been trying to convert a batch script to shell script. below is the batch script: @echo off IF "%1"== "" GOTO ARGERR REM UPDATE THESE PROPERTIES TO... (2 Replies)
Discussion started by: sukhdip
2 Replies

4. Shell Programming and Scripting

Conversion batch shell script

while converting batch file to shell script ...dis command is ther i dunno how to change...can anyone knws how to change into shell script rm !(D:\temp\XX.txt) (3 Replies)
Discussion started by: monisha
3 Replies

5. Shell Programming and Scripting

Shell Script for Epoch Time Conversion

Hi there I came across this script online to convert Epoch time to proper date format, but I am receiving the following error Also, I have HISTTIMEFORMAT set in user's .profile so that their history output shows time stamps. Additionally I have changed their .history location to a dedicated... (9 Replies)
Discussion started by: hedkandi
9 Replies

6. Shell Programming and Scripting

Conversion of below Tabs Tex file into CSV format file : shell script needed

Request if some one could provide me shell script that converts the below "input file" to "CSV format file" given Name Domain Contact Phone Email Location ----------------------- ------------------------------------------------ ------- ----- ---------------------------------... (7 Replies)
Discussion started by: sreenath1037
7 Replies

7. Shell Programming and Scripting

shell or perl script needed for ldif file to text file conversion

This is the ldf file dn: sdcsmsisdn=1000000049,sdcsDatabase=subscriberCache,dc=example,dc=com objectClass: sdcsSubscriber objectClass: top postalCode: 29600 sdcsServiceLevel: 10 sdcsCustomerType: 14 givenName: Adelia sdcsBlackListAll: FALSE sdcsOwnerType: T-Mobile sn: Actionteam... (1 Reply)
Discussion started by: LinuxFriend
1 Replies

8. Shell Programming and Scripting

Shell script for CSV conversion

thanks for allowing me join your forum i have an output of linux command "who" which provides following details..... CURRENT USER/ACCT INFO 17:31:36 up 4:49, 4 users, load average: 0.03, 0.04, 0.00 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root :0 - 12:59 ?xdm? 4:54 0.02s /bin/sh /usr/bi... (1 Reply)
Discussion started by: ayyappancheta
1 Replies

9. AIX

Need timestamp conversion shell script !!

Can anyone provide me with a ksh or bash script which will accept a timestamp (format is YYYY-MM-DD-HH24.Mi.Ss) and time offset (in hours). The output will be (timestamp passed - time offset passed deducted from it) in the same YYYY-MM-DD-HH24.Mi.Ss format. Basically I am trying to convert the... (1 Reply)
Discussion started by: shibajighosh
1 Replies

10. Shell Programming and Scripting

shell script conversion to binary

My question is: i have a script called getevent to run i just call ./getevent can i convert this to make it binary executable and not letting my clients open it and see the code.??:( I am using Solaris 8. (3 Replies)
Discussion started by: bcheaib
3 Replies
Login or Register to Ask a Question