The UNIX and Linux Forums  

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
case statement c00kie88 Shell Programming and Scripting 2 10-12-2008 06:08 PM
If or Case Statement Ernst UNIX for Dummies Questions & Answers 1 09-24-2008 06:00 PM
case statement bkan77 Shell Programming and Scripting 5 09-11-2007 06:54 PM
Case Statement Zeta_Acosta Shell Programming and Scripting 19 04-06-2004 05:16 PM
case statement Bab00shka Shell Programming and Scripting 1 07-15-2002 06:31 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 11-13-2008
ross_one ross_one is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 1
Case statement/sed command

The file dbnames.txt has 5 columns, what i'm trying to do is that when the fifth column equals A, store in the variable "access" the word, "admin access". If it equals B, then "business access" etc. I think their is a problem with my sed command, because it is not substibstituting the words correctly. Any ideas?

thanks,

ross_one

tput cup 13 0; echo "Enter your name:"
tput cup 13 16; read name
location=`find dbnames.txt`
x=`grep -c "$name" "$location"`
if [ $x -gt 0 ]
then
tput cup 15 0; echo "Name found!"
grep "$name" "$location" | cut -f 1,2,3,4,5 -d, | tr ',' ':' > temp.txt
y=`grep -F "$name" "temp.txt" | cut -f5 -d:`
case "$y" in

"A")
access="Administrator access" ;;
"B")
access="Business access" ;
"C")
access="Secretary access" ;;
*)
access="General access" ;;
esac

sed -e "s/A/$access/i" -e "s/B/$access/i" -e "s/S/$access/i" -e "s/G/$access/i" < temp.txt > test2.txt

cat test2.txt

fi

Last edited by ross_one; 11-13-2008 at 12:01 PM..
 

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