Register
It is currently Wed Oct 01, 2014 6:21 pm

Basic variable


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Tue Dec 02, 2008 3:51 pm   

Joined: Tue Dec 02, 2008 3:47 pm
Posts: 1
this is what ive got :


Code:
let nextUID="$(expr (( tail -n 1 UIDs ) + 1))"


this is basic, the error im getting is syntax unexpected (

UIDs is a variable that IS working its a fild with all my systems UIDs and i used tail to get the last one, basicly nextUID needs to be set to the next UID but why doent this work??[/code]


Top
 Profile  
 PostPosted: Thu Dec 04, 2008 7:32 am   

Joined: Mon Nov 17, 2008 7:25 am
Posts: 221
First of all, you don't need to expr when using let. it can add that for you by just doing
Code:
let nextUID=UIDs+1


But, the UIDs tail part. You cannot tail a variable unless you do something silly like a here document redirect.
I would do something like this if you want to get the next UID.
Code:
uid=$(tail -n1 /etc/passwd | cut -d":" -f3)
let nextUID=uid+1
echo $nextUID


Best regards
Fredrik Eriksson


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP