Check if passed arguments is users


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Check if passed arguments is users
# 1  
Old 10-24-2010
Check if passed arguments is users

i want to check passed arguments one by one and if it is user print home director of that user
# 2  
Old 10-24-2010
Show us what you did so far, give more clue about your input and also give a sample of what output you expect.
# 3  
Old 10-24-2010
the input will be by user like " user1 user2 anytext "
and the out put must be like
"user1 is user "
"user2 is user "
"anytext not a user"
# 4  
Old 10-24-2010
It is just an example since you don't give much information, i suppose you have root access and that your are using a standard /etc/passwd
Code:
for i in $*
do
awk -F: -vU=$i '($1==U) {print "user:"$1" homedir:"$6}' /etc/password
done

This User Gave Thanks to ctsgnb For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How can multiple arguments be passed to shell script?

My requirement is that I want to pass similar argument to a shell script and process it in the script. Something like below: myScript.sh -c COMPONENT1 -c COMPONENT2 -a APPNote: -c option can be specified multiple times and -a is optional parameter I know this can be achieved using... (2 Replies)
Discussion started by: rajdeep_paul
2 Replies

2. Shell Programming and Scripting

Shell script that check the argument passed to it and prints error if test condition is not met

I want to make a script that check for the argument passed to it and generates an error in case any character/string argument passed to it. I am using below code, but its not working. can anyone help. #!/bin/bash if ]; then echo 'An integer argument is passed to the script hence... (3 Replies)
Discussion started by: mukulverma2408
3 Replies

3. Shell Programming and Scripting

Deleting columns passed as arguments to the script

Hi all, I am trying to delete columns in a file using a script. The columns that need to be deleted are passed as arguments to the script. The script should look like this > delete_columns.sh <file_name.txt> <column_numbers_to_be_deleted> The contents of the file_name.txt will be like ... (5 Replies)
Discussion started by: VNR
5 Replies

4. Shell Programming and Scripting

Store all the passed arguments in an array and display the array

Hi I want to write a script which store all the parameters passed to the script into an array. Once it is stored I want scan through the array and and delete those files for last month present inside the directory. The files in directory is appneded with YYYY_MM_DD. I want to know how can I... (3 Replies)
Discussion started by: dgmm
3 Replies

5. UNIX for Advanced & Expert Users

Function not called when no arguments is passed

Hi Guys, I am trying to pass arguments to the script i am wrinting. When no argument is passed or wrong argument is passed, the script needs to output the way it needs to be called and exit. Currently, when no arguments is passed, it is not getting exited but goes on assuming those... (3 Replies)
Discussion started by: mac4rfree
3 Replies

6. Red Hat

how can i know what arguments are passed to a pre install rpm script?

hi, i have an rpm, and i am looking at the presinstall script. i can see it takes in an argument, but what i do not know is how this argument is passed to the script? is there something that calls the preinstall script? i thought the preinstall script was the first thing executed. thanks (2 Replies)
Discussion started by: JamesByars
2 Replies

7. Shell Programming and Scripting

How to pass arguments to SQL file passed in shell script?

Hi, I am using SYBASE database. in my script i am connecting to DB via using isql. isql -U${S_USER} -S${S_SERV} -D${S_DB} -P${S_PWD} -b0 -w3000 -h0 -s"|" -i${MYDIR}/ABC.sql -oXYZ.txt << FINSQL i am taking a ABC.sql file to use the queries written in it and storing the output in... (3 Replies)
Discussion started by: dazdseg
3 Replies

8. Shell Programming and Scripting

How to check that passed parameters all have the same extension?

$ ls monkey.txt banana.csv tree.txt $ myscript monkey.txt tree.txt All extensions ARE alike. $ myscript *txt All extensions ARE alike. $ myscript monkey.txt banana.csv All extensions are NOT alike. $ myscript * All extensions are NOT alike. My brain has given up; what's the simplest... (11 Replies)
Discussion started by: cs03dmj
11 Replies

9. Shell Programming and Scripting

count no of arguments passed to a function

hi i have a function abc { //from this function i am passing args to antoher function like def a b c j k l } now i want to count the no of args coming to def() function and iterate over those values is there any way to do this one please help (2 Replies)
Discussion started by: satish@123
2 Replies

10. Shell Programming and Scripting

Check if argument passed is an integers

How do I check if the argument passed to a script is an integer? I am writting a script that will take to integers and want to be able to check before I go on. I am using bourne shell. Thanks in advance (13 Replies)
Discussion started by: elchalateco
13 Replies
Login or Register to Ask a Question