my "case" doesn't work !


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting my "case" doesn't work !
# 1  
Old 09-30-2004
my "case" doesn't work !

I'm using the case statement in the following script and it always takes the "*" default choice while it should be "3".
I wonder why ???

dt_auj=`date +%d`

NBLOG=`ls -al /users/notes01/LOG/t*|awk '{print $7}'|grep $dt_auj|wc -l`

case $NBLOG in
1) cat ~/LOG/console-notes > $fic_tmp1 ;;
2) cat ~/LOG/console-notes ~/LOG/console-notes.0 > $fic_tmp1 ;;
3) echo "c'est le 3" ;;
4) cat ~/LOG/console-notes ~/LOG/console-notes.0 ~/LOG/console-notes.1 ~/LOG/console-notes.2 > $fic_tmp1 ;;
*) echo "c'est étoile" ;;
esac

somebody can help ?

thanks in advance

Christian
# 2  
Old 09-30-2004
Comment out the case statement and just do an
echo "$NBLOG"

What's the value?

You might find there's a leading zero or whitespace to take care of.

Cheers
ZB

Last edited by zazzybob; 09-30-2004 at 11:24 AM..
# 3  
Old 09-30-2004
You're right , the value is in fact " 3" in place of "3".

Should i use any typeset command to keep only the value "3" ?

Christian
# 4  
Old 09-30-2004
I corrected the NBLOG as :

NBLOG=`ls -al /users/notes01/LOG/t*|awk '{print $7}'|grep $dt_auj|wc -l|cut -c8 `

to suppress the blanks and it's ok !

Is there another to do this because we could have more than 8 columns ?

Christian
# 5  
Old 09-30-2004
It's not very nifty, but pipe to awk
....| awk '{print $1}'

instead of cut, at the end of your pipe-chain

Cheers
ZB
# 6  
Old 09-30-2004
That's fine !!!

thanks

Christian
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script: "mkdir -p" doesn't work with var(cat x)

Hello, :) I've an issue with the creation of a directory, All work without it :mad: So, below, my scripts with the debug output : #!/bin/bash # PATHS HOME_BACKUP="/home/backup" HOME_SCRIPT="/home/scripts/test/backup_server" TARGET="/var/www" # DATE DATE_Ymd=$(date +%Y-%m-%d) #... (1 Reply)
Discussion started by: Arnaudh78
1 Replies

2. Shell Programming and Scripting

Why doesn't "grep -w" ALWAYS work?

Working with IP addresses is a pain... Here's my problem: I'm putting some interface information to a file: 3.185.201.2 | Tu1102 152.162.54.130 | Gi0/2.36 3.185.226.2 | Gi0/1 3.185.0.82 | Tu1 ... (12 Replies)
Discussion started by: turk22
12 Replies

3. AIX

AIX 5.3 on p275 - "|" key doesn't work (!)

More issues. The "|" key doesn't work at all, either in the text terminal or in mwm (which starts fine when I do "startx"). How am I supposed to troubleshoot without a "|" key? (2 Replies)
Discussion started by: smithfarm
2 Replies

4. AIX

"/" doesn't work on command prompt for searching commands last typed

When I use "/" to look for a particular command that I typed in the current session it says D02:-/home/user1/temp> /job ksh: /job: not found. D02:-/home/user1/temp> previously it used to fetch all the commands which had job in it.. for example subjob, endjob, joblist etc... may I... (7 Replies)
Discussion started by: meetzap
7 Replies

5. UNIX for Dummies Questions & Answers

Help! "grep" doesn't work for me!

totally pis*ed off. I have a data set (xxx.txt), as follows: chr1 3821 rs127372 A/C 0.823 chr1 3822 rs127376 A/C/G 0.899 chr1 3722 rs612634 A/C 9.22 chr1 3262 rs7152 A/T 0.22 chr1 3711 rs737 A/C/G 0.2323 ....... I only want to get those lines... (6 Replies)
Discussion started by: kaixinsjtu
6 Replies

6. UNIX for Advanced & Expert Users

sometimes "ps -elf" command doesn't work

when i give "ps -elf" or "ps" system gets hung. if i press "^c" come out from it... pls help..what should i do to get it resolved. thanks CKanth (4 Replies)
Discussion started by: srikanthus2002
4 Replies

7. Linux

By angle-brackets/"pipe" button doesn't work?

How can I configure it? I have a swedish keyboard with swedish keyboard setting. Everything works perfectly (åäö) except that button. What can be wrong? /Richard ++ NOTE: It seems like the computer notices the input but that the button isn't assigned to anything (the keyboard-cursor stops).... (1 Reply)
Discussion started by: riwa
1 Replies

8. UNIX for Dummies Questions & Answers

Why "@z=$x+$y" doesn't work?

253 lab2-36:~/try_direct/another> set x=1;set y=2;@z=$x+$y @z=1+2: Command not found. 254 lab2-36:~/try_direct/another> (11 Replies)
Discussion started by: endeavour1985
11 Replies
Login or Register to Ask a Question