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
Script not working..."sort" not working properly.... Rahulpict Shell Programming and Scripting 23 03-16-2009 11:13 AM
GUI not working... CLI is working fine bharu_sri SUN Solaris 4 12-23-2008 12:35 AM
who not working ranj@chn UNIX for Advanced & Expert Users 4 04-26-2007 10:16 AM
RSH not working jhansrod AIX 1 06-04-2005 03:42 PM
rsh not working bcheaib UNIX for Dummies Questions & Answers 2 11-22-2004 09:40 AM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 06-09-2009
climbwave climbwave is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 3
If/else is not working. Why?

Hi all,

It's my first post on forum - saying HELLO

I have a simple script and would like to improve it.
When [user] in terminal writing correct file name then designed file making grep, etc.But if [user] writing wrong file name then warning should appear in terminal.

This script doesn't work properly. Can you tell me why, please


Code:
#!/bin/bash 

##############################################
#Script is taking C,E,V records from P1 file
#
#############################################

#Direction of P1 file
P1_DIR='/home/sprint/Desktop/jacek/test/'
CEV_DIR='/home/sprint/Desktop/jacek/test/cev/'
ERR1="File does not exist - try again with correct file number"

#Some description how it works
echo ""
echo "Hello!"
echo ""
echo "Script will create C, E, V records from P1 file"
echo ""
echo "Type file name without prefix & extension - example 123456023A"
echo ""

read filename

cd $P1_DIR

#It's taking H,C,E,V records from P1 file
if [ -f NSR$filname.p190 ]; then

#It's taking ...
grep ^H NSR$filename.p190 > hdr 
grep ^C NSR$filename.p190 > Crec 
grep ^E NSR$filename.p190 > Erec 
grep ^V NSR$filename.p190 > Vrec 

#it's creating E,V,C records and save as we want :)
cat hdr Erec > "NSR${filename}_Erec.p190" 
cat hdr Vrec > "NSR${filename}_Vrec.p190" 
cat hdr Crec > "NSR${filename}_Crec.p190" 

#cd $P1_DIR
mv $P1_DIR"NSR${filename}_Erec.p190" $CEV_DIR 
mv $P1_DIR"NSR${filename}_Vrec.p190" $CEV_DIR 
mv $P1_DIR"NSR${filename}_Crec.p190" $CEV_DIR 

echo ""


else
    echo "$ERR1"
    exit 1
fi

 

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:42 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