Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a file on a server on another campus that's all in lowercase that i need to changed to all uppercase. Is there any simple unix command that will do this? [i'm using PuTTy on a PC if that makes any difference.]

It's only 4 different letters (it's DNA, so just A, T, C, and G) so 4 separate search and replace functions would also work. (In VI or another text editor which will work through remote access.) but i don't know how to do a search and replace in VI?

I could copy it to my desktop, do a search and replace in a local text editor and then copy back, but then it would end up full of windows line breaks? [i'm on a PC, the remote machine is a linux server, and the program i need to interpret the DNA file can only handle unix line breaks.]

share|improve this question
up vote 4 down vote accepted

You don't need to open the file in an editor you can use tr to (t)ranslate (c)characters (man page) directly:

tr '[:lower:]' '[:upper:]' < input.txt > output.txt
share|improve this answer

This would be the VI solution. If you only want to replace those characters to the uppercase equivalent


And for all characters


Explanation: s(ubstite) [actg] regular expression for those characters, or [a-z] for the range. \U\0 means: changes the matching pattern to uppercase g replace all occurences

Advised reading:

share|improve this answer

Im sure others will come around with more elegant solutions, but since your alphabet is limited to just 4 letters, you can just do this

sed 's/a/A/g;s/t/T/g;s/c/C/g;s/g/G/g' <filename>

if this works correctly you can add > <filename> or sed -i ... to save to the file

Check out wikipedia for more info

share|improve this answer
is sed just a unix command? – Kirstin Oct 5 '12 at 6:07
yup, you should find it on any unix type system - my testing was done on a mac for example – Karthik T Oct 5 '12 at 6:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .