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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check variable contents 1

Status
Not open for further replies.

tempest92

Technical User
Sep 16, 2003
110
GB
hi,

can someone please tell me how i would test if a variable contains a space (this is information put in by users via a menu option).

the variable should be v1="a1,a2,a3,a4,a5" but i need to check that it is not v1="a1, a2,a3,a4,a5" for example.

Thanks in advance !!
 
Why not let your program handle it a bit user-friendly: just squeeze the whitespace out after the user has entered the value...

something like:

...
read answer
answer=$(echo "${answer}"|tr -d '[ \t]')
...


HTH,

p5wizard
 
thanks p5wizard, this is just what i was looking for !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top