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
 
LinkBack Search this Thread
Old 02-18-2012, 06:58 AM   #31
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 507

Original Poster
Rep: Reputation: 31

The following is a good if-then-else :

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

Rep: Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009
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 11:36 AM.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are 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


All times are GMT -5. The time now is 02:00 PM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration