If first letter of name is a-m do this if n-x do something else


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers If first letter of name is a-m do this if n-x do something else
# 1  
Old 03-12-2009
If first letter of name is a-m do this if n-x do something else

so if I run echo $USER and the name is smithr i want to run command B to run because s is after m in the alphabet, but if the user is aldap I want command A to run because their first initial in the user name is in the first half of alphabet.

how please?
# 2  
Old 03-12-2009
Code:
case $USER in
  [a-m]* ) A ;;
  [n-z]* ) B ;;
esac

# 3  
Old 03-12-2009
Tools What about case?

Let me add to the previous example:

case $USER in
[a-mA-M]* ) A;;
[n-zN-Z]* ) B;;
esac

This way you'll match independent of case.
You know how "users" are! Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace specific letter in a file by other letter

Good afternoon all, I want to ask how to change some letter in my file with other letter in spesific line eg. data.txt 1 1 1 0 0 0 0 for example i want to change the 4th line with character 1. How could I do it by SED or AWK. I have tried to run this code but actually did not... (3 Replies)
Discussion started by: weslyarfan
3 Replies

2. UNIX for Dummies Questions & Answers

Delete all words not containing letter /s/

I have a word file that looks like: pens binder spiral user I want to delete all the words without the letter /s/, so output looks like: pens spiral user I tried using sed: sed '//d' infile.txt > out.txt (5 Replies)
Discussion started by: pxalpine
5 Replies

3. Programming

Problem of first letter

i have function to send arabic notification email to employee , but when i open the email in outlook i see that the first letter of the caption (employee name) is trimed , but when i open the same email from other workstation i see the caption is complete (working fine) (1 Reply)
Discussion started by: AimyThomas
1 Replies

4. Shell Programming and Scripting

Taking letter from a word

Hi All, I am new to UNIX and i am trying to write a script.My requirement is that from the following logs i need to get the following outputs: abc_lifecycle.log bcde_enjoy.log abc_twinkle.log Output expecting: lifecycle enjoy twinkle Could you please help me in getting this? (9 Replies)
Discussion started by: JeiPrakash
9 Replies

5. Shell Programming and Scripting

get only two letter from any string

I want get middle two latter of any string. Input: var="070108" output: var1="01" please help. (2 Replies)
Discussion started by: rinku
2 Replies

6. Shell Programming and Scripting

what is dead.letter ??

Hi all can you please help me what is dead.letter file ? when it is created ? for the first time i have seen this file getting created in my current directory? I am using SunOs. Any IDEA ?? (2 Replies)
Discussion started by: jambesh
2 Replies

7. UNIX for Dummies Questions & Answers

SORT by letter

Hello again, Since I am UNIX new user I have this question: I have this file: 1 A A 1 A A 1 A A 1 B B 1 B B 1 X X 1 X X 1 C C Could anyone of you help me to sort this file like this: (I need all A and X together) 1 A A 1 A A (1 Reply)
Discussion started by: murbina
1 Replies

8. UNIX for Dummies Questions & Answers

dead.letter

HI, I am pretty new to Unix...but here is 1 serious problem...atleast for me..:-) now..the dead.letter file in /var/tmp has been growin continuously..n i dont know why..I ve even killed the sendmail process..but the dead.letter file keeps on increasin..Can anyone tell me where do I start... (6 Replies)
Discussion started by: unisam
6 Replies
Login or Register to Ask a Question