38.107.191.111 |    

Navigation

Google Advertisement

Die Funktion rtrim() ist der gleichnamigen PHP Funktion nach empfunden. Sie entfernt Whitespaces am Ende eines Strings. Die Funktion kann den String als Parameter $1 aber auch durch STDIN entgegen nehmen.

rtrim
  1. # ***************************************************************************
  2. # This function removes whitespace at the end of a string.
  3. #
  4. #  @param string $1 string (optional, can also handle STDIN)
  5. #  @return string
  6. #  @example:    echo "That is a sentinece " | rtrim
  7.  
  8. function rtrim() {
  9.  
  10. if [ -n "$1" ]; then
  11.         echo $1 | sed 's/[[:space:]]*$//g'
  12. else
  13.         cat - | sed 's/[[:space:]]*$//g'
  14. fi
  15.  
  16. }
Parsed in 0.017 seconds at 24.83 KB/s

Search
 
Full text search by name and content of a snippet.

User online
There are 6 users online.

Tags Cloud

Latest snippets
urlencode
(Perl::Function)
gethostbyaddr
(Perl::Function)
create_function
(JavaScript::Snippets)
function_exists
(JavaScript::Snippets)
listing
(PHP::Function)
runPhpCode
(PHP::Function)
md5
(Bash::Function)
rtrim
(Bash::Function)
ltrim
(Bash::Function)
function_exists
(Bash::Function)