Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cp command for different users

Status
Not open for further replies.

props

Technical User
Nov 22, 2003
17
GB
cp file /home/ugrad/gtr954/backup
another user
cp file /home/ugrad/rtw567/backup


i have a command in my script that copies a file on a different user's backup folder.
any idea how to write this down?
 
You can try something like this:
Code:
case $LOGNAME in
user1) cp file /home/ugrad/gtr954/backup;;
user2) cp file /home/ugrad/rtw567/backup;;
*) cp file /home/ugrad/default/backup;;
esac
Or simplier if gtr954 and rtw567 are the login names:
Code:
[ -d /home/ugrad/$LOGNAME/backup ] &&
  cp file /home/ugrad/$LOGNAME/backup



Hope This Help
PH.
 
Yeap thats it thank you very much happy new year
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top