Advertisement
zamotivator

Untitled

Jun 14th, 2013
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.34 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. function drop_first ()
  4. {
  5.     local line
  6.     # skip
  7.     read line;
  8.     # proxy
  9.     while read line; do
  10.     echo $line;
  11.     done;
  12. }
  13.  
  14. function join ()
  15. {
  16.     local delimeter="$1"
  17.     sed -e "s/^/${delimeter}\n/g" | drop_first | xargs
  18. }
  19.  
  20. echo "1a 1b
  21. 2a 2b 2c
  22. 3a" | drop_first | join "delim"
  23.  
  24. # result: '2a 2b 2c delim 3a'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement