Find the answer to your Linux question:
Results 1 to 3 of 3
hello every one I have a problem that drove me crazy last couple days I know I have to use loop structures but I can't figure out how to put ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2011

    looping problem in UNIX script please help

    hello every one
    I have a problem that drove me crazy last couple days I know I have to use loop structures but I can't figure out how to put the right pieces together. I'm not asking for a complete answer because I want to learn so please help me out
    The problem says
    write a shell script that will take the information from two files and combine into another file
    I created both files in vi and they are

    David 734.854.5643
    Roberto 313.432.4532
    Sally 267.423.5412
    Mary 435.432.7654
    Ted 324.642.6743
    Alice 234.576.3245
    Frank 342.465.6754

    and the second file is

    Roberto Tuesday 2
    Sally Monday 8
    Ted Sunday 16
    Alice Wednesday 23
    David Thursday 10
    Mary Saturday 14
    Frank Friday 15

    The output file should be like this:
    Name----------------On-Call--------------------Phone------------------Start Time
    Sally---------------- Monday ---------------267.423.5412-----------------8am

    I noticed right away that there is a common thing between the two files (the name), and I thought i could use for loop to cut pieces using the day of the week because I have to sorted in a specific order starting from Monday so I thought this loop might work:

    for day in Monday Tuesday Wednesday Thursday Friday Saturday Sunday
    grep $day file2

    I know it is not complete but I just wanted you to know how I should do the sort. And there is another problem which is the time. in the file is in 24 hours format i have to convert it to 12 hours format.
    And that is it for now I want you guys just to tell me how to start and how to put the pieces together.
    your help us appreciated
    Thank you very much

  2. #2
    Just Joined!
    Join Date
    Oct 2011
    64 views and no help

    help me out here guys please.

  3. #3
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Seattle, WA, USA
    This sounds a lot like a homework question, which are not allowed on this forum. Therefore, I will be closing this thread.

    You are correct that you can use grep to find which lines contain a given word. Have you considered using cut or awk in order to get the rest of the information on that line?

  4. $spacer_open

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts