Script requirement

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Script requirement
# 1  
Old 10-25-2015
Script requirement

Please help in creating script for below requirement.

I will be running 1 command and will get below entries in a text file say file44.txt
DFDL1005 06:30 00:05
ABFL2003 10/22 01:10
CFTL1256 10/24 00:10

10/25 09:20 PM


Now I need a script to add column 2nd and column 3rd entries and compare it with current time(HH:MM format) and if it exceeds more than 15 min then I should get all such column A entries printed in email body.

2.)Column 2 has entries in HH:MM and MM/DD format. I want to take above action for entries in HH:MM format and want to print list of column A entries in a separate txt file if column 2nd entry(MM/DD format) is 1 day older than current date. Rest of the entries should be discarded
Moderator's Comments:
Mod Comment Please use CODE tags when displaying sample input, sample output, and code segments (as required by forum rules).

Last edited by Don Cragun; 10-25-2015 at 04:21 PM.. Reason: Add CODE and ICODE tags.
# 2  
Old 10-25-2015
Please use code tags as required by forum rules!

A sample output based on above input data would help. How would I compare 06:30 00:05 to the current time?
Any attempts from your side?
# 3  
Old 10-25-2015
We need to add column 2 and column 3rd data and compare it with current time stamp, 06:30 + 00:05 = 06:35 and if current time is 06:55 then its 20 min difference and it should be printed in email body.

I did not try as Im new to shell scripting and finding hard to create script as per requirement, so posted it here and seeking for help. Kindly help!
# 4  
Old 10-25-2015
Is this a homework assignment? Homework assignments must be posted in the Homework & Coursework Forum and must include a completely filled out homework & coursework template.

When asking questions in these forums, it is always a good idea to tell us what operating system and shell you are using.

For questions concerning the handling of dates and times, it is crucial. Date processing on some systems is MUCH simpler than it is on some other systems. What operating system are you using?

What shell are you using? (And, if it is a Korn shell (ksh), what version is it?)

And, if you can't give us an example of what output you're trying to produce from your sample input (and a specific date and time at which the script is run), I don' see how we can help.

I have never seen a script that would be able to send an e-mail message to someone and force the recipient of that e-mail to send that message to a physical printer. I'm guessing that that isn't really what you mean, but that is what your description requires.

There are LOTS of things missing from these requirements that make creating a script for this impossible:
  1. What date applies to lines that don't have dates on them? Is it the current date? Is it the date specified on the first line before it that contains a date? Is it the date specified on the first line after it that contains a date?
  2. What year is associated with dates in column 2? Is it the current year if the date on that line is less than or equal to the current date and the previous year if the date on that line is greater than the current date? Is it always in the current year?
  3. In the requirement: "Now I need a script to add column 2nd and column 3rd entries and compare it with current time( HH:MM format) and if it exceeds more than 15 min then I should get all such column A entries printed in email body.", what does all such column A entries mean? All lines that contain the string contained in column 1? All lines that contain the string contained in column 1 in column 1? Just print column 1 from lines where column 2 + column 3 + 15 minutes is earlier in the day than the current time in the current day? Please give us a clear specification of what you are trying to do!
There are other ambiguities in your requirements. Please write clear requirements and show us examples (in CODE tags) that highlight how those requirements affect the output you're trying to produce.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Writing if condition in shell script and failing to do requirement

Hi, I am trying to edit the values in a file. For example i am trying to edit the value of "ABC" in a file by executing shell script. Please Note that ABC value can be there mulitple times or it may not be there in the file Conditions for it is 1. If ABC is less than 123 then it should... (14 Replies)
Discussion started by: darling
14 Replies

2. Shell Programming and Scripting

Help to write a script for the below requirement

Hi, I am not so familiar with shell Script but I have a task in hand. So, here it goes: There is a file details.txt in the server where the below details are stored: Name Country D M Acc.No. sameer India 30 july sscc-errttt-q random US 20 july pecc-ttt4-s Deb India 31... (3 Replies)
Discussion started by: neel87
3 Replies

3. Shell Programming and Scripting

UNIX - requirement

Hi All, I have a source file with data Name ~ Groups Muni~abc,was,USA_ax,123 Chaitanya~USA_12,was Balaji~123,xyz,was Ramu~123,xyz From the second column i want to extract only the groups that matches the pattern 'USA_%' or if the group = 'was', and ignore any other columns. ... (8 Replies)
Discussion started by: morbid_angel
8 Replies

4. Shell Programming and Scripting

How to write bash shell script for mentioned requirement?

Hi All, I am unable to write the script for the below requirement. Requirement: Main table dir_ancillary table contain three column "dir_ancillary.table_name"," dir_ancillary.text_file_name ", "dir_ancillary.Include" . This dir_ancillary contain undefined tables in the column... (2 Replies)
Discussion started by: Vineeta Nigam
2 Replies

5. Shell Programming and Scripting

complex requirement

i have a requirement to search a pattern1 and once the pattern1 is found i have to go up and search pattern2 and if pattern2 is found i have to search down for pattern3 and pattern4. once this cycle is compelted, again i have to search pattern1 and pattern2,3,4 i am able to do this by opening... (9 Replies)
Discussion started by: tnvanathy23
9 Replies

6. Shell Programming and Scripting

Awk script with a urgent requirement

The Problem content is pin (AND1) { dir : output; cap : hot; tran: slew; } need to write a awk script which can search the Pin AND1 and then tran of the Group pin(AND1) and then insert the code from the file "insert_code" . insert_code file contents . It is a Big file the script should... (3 Replies)
Discussion started by: kshitij
3 Replies

7. Shell Programming and Scripting


I am trying to script and came up with a conclusion that I need a do while loop in my statement. I am stuck with the do while syntax. I need to use it alongwith the if then else statement. Can I use it is a big question? I actually need to get all the files that are there from within run_dt to... (1 Reply)
Discussion started by: aronmelon
1 Replies

8. Shell Programming and Scripting

Required Shell script for My requirement

Hi All, I joined today in this forum to have all of your help. I have a Big requirement, pls. help me to resolve. I'm using HP-UX 11.23. I need a shell script for the following requirement. I have a file (nodes.txt) that contains 1000 nodes. I'm running the following command:... (3 Replies)
Discussion started by: ntgobinath
3 Replies
Login or Register to Ask a Question

Featured Tech Videos