![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 |
| Display Modes | Rate This Thread |
|
|