user3781201
user3781201

Reputation: 1301

How to use the Unix tr command on a file in max os X

In Mac OS X Terminal, I can't seem to use the 'tr' command on a file.

For example, I have a text file called 'z.txt' on my desktop. I would like to substitute every letter 'a' into the letter 'e'.

tr "a" "e" z.txt

returns the following message:

usage: tr [-Ccsu] string1 string2
       tr [-Ccu] -d string1
       tr [-Ccu] -s string1
       tr [-Ccu] -ds string1 string2

Conversely, this works just fine:

sed "s_a_e_g" z.txt

What syntax or quoting should I use to make the 'tr' approach work?

Upvotes: 3

Views: 9101

Answers (1)

Praxeolitic
Praxeolitic

Reputation: 24089

You can direct the file into tr.

tr "a" "e" < z.txt

Upvotes: 1

Related Questions