# Command line with regexp same as script but didn't work

**URL:** <https://www.ruby-forum.com/t/command-line-with-regexp-same-as-script-but-didnt-work/96548>\
**Category:** Ruby\
**Created:** [June 29, 2006, 4:00pm UTC](https://www.ruby-forum.com/t/command-line-with-regexp-same-as-script-but-didnt-work/96548 "2006-06-29T16:00:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![agouti](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/59ef9b/32.png) [@agouti](https://www.ruby-forum.com/u/agouti)\
**Post date:** [June 29, 2006, 4:00pm UTC](https://www.ruby-forum.com/t/command-line-with-regexp-same-as-script-but-didnt-work/96548/1 "2006-06-29T16:00:41Z")

</div>

hello !  
i have to comment a link in lots html pages of a static site (with  
tables everywere ) :  
with my little ruby script :

```
while get
   gsub(/()/, '')
  print
end
```

it ok , but when i try try with command line :

```
cat file.html | ruby -pe 'gsub(/()/, '')'
```

i got a error :

```
e:1:in `gsub': can't convert Fixnum into String (TypeError) from 
-e:1
```

anybody can tell me why ??  
(sorry for my bad english)

---

<div class="post-metadata">

**Author:** ![agouti](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/59ef9b/32.png) [@agouti](https://www.ruby-forum.com/u/agouti)\
**Post date:** [June 29, 2006, 5:21pm UTC](https://www.ruby-forum.com/t/command-line-with-regexp-same-as-script-but-didnt-work/96548/2 "2006-06-29T17:21:19Z")

</div>

On 29/06/06, agouti agouti [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> it ok , but when i try try with command line :
> 
> ```
> cat file.html | ruby -pe 'gsub(/()/, '')'
> ```
> 
> i got a error :

Perhaps it’s because you tried to nest single quotes within single  
quotes. You need to use something else instead, like double quotes or  
%q (equivalent to '):

cat file.html | ruby -pe ‘gsub(/(\<td._agenda._/td\>)/, %q())’

Paul.

---

<div class="post-metadata">

**Author:** ![agouti](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/59ef9b/32.png) [@agouti](https://www.ruby-forum.com/u/agouti)\
**Post date:** [June 29, 2006, 5:24pm UTC](https://www.ruby-forum.com/t/command-line-with-regexp-same-as-script-but-didnt-work/96548/3 "2006-06-29T17:24:31Z")

</div>

On Jun 29, 2006, at 10:00 AM, agouti agouti wrote:

> it ok , but when i try try with command line :  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

I suspect it’s a quoting issue. I would try:

ruby -pe ‘gsub(/(\<td._agenda._/td\>)/, %q{})’

Note that you also double those \ depending on your shell (e.g. \1  
instead of just \1 )
