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
help me in sending parameters from sqlplus script to unix shell script Hara Shell Programming and Scripting 2 01-29-2008 03:31 PM
Shell Script: want to insert values in database when update script runs ring Shell Programming and Scripting 1 10-25-2007 04:06 AM
here document to automate perl script that call script hogger84 Shell Programming and Scripting 3 10-22-2007 11:15 AM
returning to the parent shell after invoking a script within a script gurukottur Shell Programming and Scripting 5 09-26-2006 08:05 AM
return valuse from child script to parent script borncrazy Shell Programming and Scripting 1 08-20-2004 04:39 PM

Closed Thread
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
  #1 (permalink)  
Old 07-29-2006
bwilson621 bwilson621 is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 2
Need help with my script

Hello all, I am brand new to scripting and need a bit of help on a starter script I am writing.

The point of the script is to pull out select information from different lines in a file (based off of current date), and print them out. Right now my output reads like:


Code:
Group:   BRIAN BRIANWIL
Allotted: 13 10
Booked:   8 0
Cancelled: 1 0

But I would like to have it sorted so it would read like:

Code:
Group           Allotted            Booked          Cancelled
BRIAN             13                    8                    1
BRIANWIL          10                    0                    0

My current script looks like:

Code:
#!/bin/sh
echo "Enter today's date (Ex. 07/26/2006)"
read date

group=`dbclist bdwwblok.txt:bdw|grep $date| cut -c 1-8`
n=`dbclist bdwwblok.txt:bdw|grep $date| cut -c 33-34`
m=`dbclist bdwwblok.txt:bdw|grep $date| cut -c 37-38`
o=`dbclist bdwwblok.txt:bdw|grep $date| cut -c 47-48`

echo "Group:  "    $group
echo "Allotted:" $n
echo "Booked:  " $m
echo "Cancelled:"$o

And a sample line from the file I am working with is:


Code:
BRIAN   24539431QN  07/26/2006  13   81  10    1    0


Can somebody please tell me what I am doing wrong? I know that it's extremely basic, but I'm just trying to teach myself and get this working. Thanks in advance if somebody can at least point me in the right direction.

Last edited by reborg; 07-29-2006 at 07:51 PM..
  #2 (permalink)  
Old 08-01-2006
bwilson621 bwilson621 is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 2
Nevermind, I got it to work how I wanted it to. The coding goes like this:


Code:
groupfix()
{
        file="wblok.txt"
        type="bdw"
        dir="/u/imag10.1/files/bdw/"
        echo "Today's date is:" `date`
        echo "Enter date needed: (ex. 07/26/2006)"
        read date
        output=`grep $date $dir$type$file | cut -c1-8,33-34,37-38,47-48 | wc -l`
        echo " "
        echo "$output groups in hotel today"
        echo "Group Information (Group Name, Allotments, Booked, Cancelled)"
        for i in $file
        do
                grep  $date $dir$type$file | cut -c1-8,33-34,37-38,47-48
        done
        return
}

Closed Thread

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 06:35 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