Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-18-2012, 06:58 AM   #31
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 674

Original Poster
Rep: Reputation: 34

The following is a good if-then-else :

if [[ $Number -eq 0 ]]; then
Old 02-18-2012, 11:31 AM   #32
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,577
Blog Entries: 31

Rep: Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196
Originally Posted by jonaskellens View Post
Number=${Number/ /} removes white spaces
It removes spaces. Your previous version, ${Number//[[:space:]]}, removes whitespace. Whitespace is any of the characters space, tab and newline.

EDIT: actually ${Number/ /} removes only the first space. ${Number// /} removes all spaces and can be more simply given as ${Number// }. Here's a command prompt illustration:
c@CW8:~$ x=' a b c '
c@CW8:~$ echo "'${x/ /}'"
'a b c '
c@CW8:~$ echo "'${x// /}'"
c@CW8:~$ echo "'${x// }'"

Last edited by catkin; 02-18-2012 at 11:36 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
diff the output of one bash script against another Finejason Linux - General 3 07-07-2011 02:41 AM
Bash Script Missing Output Slick666 Programming 1 10-05-2007 07:09 AM
Weird Nautilus Bash Script Problem fatsheep Programming 2 11-19-2006 04:51 PM
Bash Script, calculate output. eldaria Programming 13 07-20-2006 09:26 PM
bash script connect from one host to another and to another weird aim nakkaya Linux - Networking 1 06-30-2003 01:28 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:49 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration