The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script Language Parser for Learning kcampb9 UNIX for Dummies Questions & Answers 3 03-30-2008 02:21 PM
learning how to use shell script bebop1111116 Shell Programming and Scripting 3 09-18-2006 11:18 AM
learning on my own jonas27 UNIX for Dummies Questions & Answers 2 12-03-2001 08:29 PM
Learning to script...want a project to work on (making a small MUD) learningtoscrip UNIX for Dummies Questions & Answers 2 10-24-2001 01:15 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 05-23-2007
llsmr777 llsmr777 is offline
Registered User
  
 

Join Date: May 2007
Posts: 58
learning how to script

I have this command line entry that I would like to turn into a script. I want to be able to just run the script with options for the report name and switch. Can anyone help me get started? I am hoping that by creating this script it will help me be able to create more.
I have never written one. I have read a few websites but can't find a really good one yet so if you know of any taht'd be great too.

Here is the command:
cat report.20060222 |grep Detroit | nawk -F"," '{tmp+=$10} END {print tmp}'

I want to just call the script total_rawfile.ksh

Then be able to run: total_rawfile.ksh report.20060222 Detroit


Thank you in advance for any help!
  #2 (permalink)  
Old 05-23-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
total_rawfile.ksh
Code:
cat $1|grep $2 | nawk -F"," '{tmp+=$10} END {print tmp}'
  #3 (permalink)  
Old 05-23-2007
llsmr777 llsmr777 is offline
Registered User
  
 

Join Date: May 2007
Posts: 58
what did I do wrong?
I get this error:
ksh: total_rawfile.ksh: cannot execute
  #4 (permalink)  
Old 05-23-2007
kthatch kthatch is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 28
Is the script executable?

chmod +x total_rawfile
  #5 (permalink)  
Old 05-24-2007
formyz formyz is offline
Registered User
  
 

Join Date: May 2007
Posts: 12
hello

i am newer.
  #6 (permalink)  
Old 05-24-2007
llsmr777 llsmr777 is offline
Registered User
  
 

Join Date: May 2007
Posts: 58
I am so dumb!
Ok now it works.

How can I put a line so that if someone types the script name it gives it it's usage. I tried this but it didnt' work:


function USAGE
{
echo "\nUSAGE: total_rawfile.ksh <report name> <switch short ID> \n"
echo "Here is an example:\n"
echo "total_rawfile.ksh RA_FW_SL4_rawfile_report.20070520.chk_SCOUT_ARCHIVE ANAJAL\n"
}

cat $1 | grep $2 | nawk -F"," '{tmp+=$10} END {print tmp}'
#grep $2
#nawk -F"," '{tmp+=$10} END {print tmp}'


Also let's say the variable has a / so like $1 is reports/daily is there anything special needed because the variable has a / in it?

thanks for the replies. And patience!
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 07:54 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