# Join all text files in a folder, with a single line of Ruby code

**URL:** <https://rubytalk.org/t/join-all-text-files-in-a-folder-with-a-single-line-of-ruby-code/49833>\
**Category:** ruby-talk\
**Created:** [25 October 2008 11:44 UTC](https://rubytalk.org/t/join-all-text-files-in-a-folder-with-a-single-line-of-ruby-code/49833 "2008-10-25T11:44:53Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![\_Pena\_Botp1](https://avatars.discourse-cdn.com/v4/letter/_/94ad74/32.png) [@\_Pena\_Botp1](https://rubytalk.org/u/_Pena_Botp1)\
**Post date:** [27 October 2008 07:10 UTC](https://rubytalk.org/t/join-all-text-files-in-a-folder-with-a-single-line-of-ruby-code/49833/21 "2008-10-27T07:10:31Z")

</div>

# I often use -ep to get rid of quotes and "unused literal"  
# warning.

i just tried that nobu, but it gives no output

:~$ ruby -ep \*.txt  
:~$

> **···**
>
> From: Nobuyoshi Nakada [[mailto:nobu@ruby-lang.org](mailto:nobu@ruby-lang.org)]

---

<div class="post-metadata">

**Author:** ![Nobuyoshi\_Nakada1](https://avatars.discourse-cdn.com/v4/letter/n/9f8e36/32.png) [@Nobuyoshi\_Nakada1](https://rubytalk.org/u/Nobuyoshi_Nakada1)\
**Post date:** [27 October 2008 09:59 UTC](https://rubytalk.org/t/join-all-text-files-in-a-folder-with-a-single-line-of-ruby-code/49833/22 "2008-10-27T09:59:00Z")

</div>

Hi,

At Mon, 27 Oct 2008 16:10:31 +0900,  
Peña, Botp \<botp@delmonte-phil.com\> wrote in [ruby-talk:318654]:

> i just tried that nobu, but it gives no output
> 
> :~$ ruby -ep \*.txt

You needs -p option.

&nbsp;&nbsp;ruby -pep \*.txt

> **···**
>
> --  
> Nobu Nakada

---

<div class="post-metadata">

**Author:** ![\_Pena\_Botp1](https://avatars.discourse-cdn.com/v4/letter/_/94ad74/32.png) [@\_Pena\_Botp1](https://rubytalk.org/u/_Pena_Botp1)\
**Post date:** [27 October 2008 10:22 UTC](https://rubytalk.org/t/join-all-text-files-in-a-folder-with-a-single-line-of-ruby-code/49833/23 "2008-10-27T10:22:57Z")

</div>

# At Mon, 27 Oct 2008 16:10:31 +0900,  
# Peña, Botp \<[botp@delmonte-phil.com](mailto:botp@delmonte-phil.com)\> wrote in [ruby-talk:318654]:  
# \> i just tried that nobu, but it gives no output  
# \>  
# \> :~$ ruby -ep \*.txt

> **···**
>
> From: Nobuyoshi Nakada [[mailto:nobu@ruby-lang.org](mailto:nobu@ruby-lang.org)]  
> #  
> # You needs -p option.  
> #  
> # ruby -pep \*.txt
> 
> you're saying -ep is different from -e -p ?  
> i'm asking since i do not see it ruby -h
> 
> thanks for the info -botp

---

<div class="post-metadata">

**Author:** ![Nobuyoshi\_Nakada1](https://avatars.discourse-cdn.com/v4/letter/n/9f8e36/32.png) [@Nobuyoshi\_Nakada1](https://rubytalk.org/u/Nobuyoshi_Nakada1)\
**Post date:** [27 October 2008 12:17 UTC](https://rubytalk.org/t/join-all-text-files-in-a-folder-with-a-single-line-of-ruby-code/49833/24 "2008-10-27T12:17:03Z")

</div>

Hi,

At Mon, 27 Oct 2008 19:22:57 +0900,  
Peña, Botp \<botp@delmonte-phil.com\> wrote in [ruby-talk:318662]:

> # \> i just tried that nobu, but it gives no output  
> # \>  
> # \> :~$ ruby -ep \*.txt  
> #  
> # You needs -p option.  
> #  
> # ruby -pep \*.txt
> 
> you're saying -ep is different from -e -p ?  
> i'm asking since i do not see it ruby -h

Each -e needs a following expression, so 'p' after it is  
Kernel#p, however, -p doesn't take arguments so 'e' after it is  
-e.

> **···**
>
> --  
> Nobu Nakada

---

<div class="post-metadata">

**Author:** ![luisbebop](https://avatars.discourse-cdn.com/v4/letter/l/f04885/32.png) [@luisbebop](https://rubytalk.org/u/luisbebop)\
**Post date:** [27 October 2008 13:24 UTC](https://rubytalk.org/t/join-all-text-files-in-a-folder-with-a-single-line-of-ruby-code/49833/25 "2008-10-27T13:24:11Z")

</div>

Thanks for all replies. A lot of interesting solutions!

[www.twitter.com/luisbebop](http://www.twitter.com/luisbebop)

---

<div class="post-metadata">

**Author:** ![botp1](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@botp1](https://rubytalk.org/u/botp1)\
**Post date:** [27 October 2008 13:26 UTC](https://rubytalk.org/t/join-all-text-files-in-a-folder-with-a-single-line-of-ruby-code/49833/26 "2008-10-27T13:26:53Z")

</div>

dumb me. all the time i thought the quotes were required for -e and  
that a space should separate it fr the expression :))  
so now even "ruby -pe0 \*.txt" should work!

many thanks for the englightenment, nobu.  
kind regards -botp

> **···**
>
> on Mon, Oct 27, 2008 at 8:17 PM, Nobuyoshi Nakada \<nobu@ruby-lang.org\> wrote:
> 
> > Each -e needs a following expression, so 'p' after it is  
> > Kernel#p, however, -p doesn't take arguments so 'e' after it is -e.

[Previous page](https://rubytalk.org/t/join-all-text-files-in-a-folder-with-a-single-line-of-ruby-code/49833.md?page=1)
