LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 02-18-2012, 07:58 AM   #31
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 632

Original Poster
Rep: Reputation: 33

The following is a good if-then-else :

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

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
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:
Code:
c@CW8:~$ x=' a b c '
c@CW8:~$ echo "'${x/ /}'"
'a b c '
c@CW8:~$ echo "'${x// /}'"
'abc'
c@CW8:~$ echo "'${x// }'"
'abc'

Last edited by catkin; 02-18-2012 at 12:36 PM.
 
  


Reply


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 03:41 AM
Bash Script Missing Output Slick666 Programming 1 10-05-2007 08:09 AM
Weird Nautilus Bash Script Problem fatsheep Programming 2 11-19-2006 05:51 PM
Bash Script, calculate output. eldaria Programming 13 07-20-2006 10:26 PM
bash script connect from one host to another and to another weird aim nakkaya Linux - Networking 1 06-30-2003 02:28 PM


All times are GMT -5. The time now is 02:37 AM.

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