ssh - how do i turn a whole file into uppercase?

08
2014-07
  • Kirstin

    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.]

  • Answers
  • Matteo

    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
    
  • Bernhard

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

    :s/[actg]/\U\0/g
    

    And for all characters

    :s/[a-z]/\U\0/g
    

    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: http://vimregex.com/#substitute

  • Karthik T

    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


  • Related Question

    ssh - how do I change the colour scheme on PuTTY
  • Kirstin

    I'm using PuTTY to SSH from my PC at home to Linux computers at work, but some of the text (folder names) is dark blue on black, which is almost impossible to read. How do I change the colour-scheme?

    My computer at home has Windows 7 in case it makes any difference.


  • Related Answers
  • ubiquibacon

    In the putty configuration window on the left side (the category section) there is an expandable item called Window and under that item is Colours. That is where color changes can be made.

  • Dennis Williamson

    Click on the System menu at the upper left corner of the PuTTY window.

    • Select Change Settings > Window > Colours.
    • In the box that says "Select a colour to adjust", choose ANSI Blue and click the Modify Button.
    • Slide the black arrow on the right up until you see a lighter shade of blue that you like.
    • Click OK.
    • Perform the same steps for ANSI Blue Bold so you can have a perceptible difference between the two.
    • When you're finished, click Apply.
  • Dave

    You may also want to make those colour changes to the default session so that all future sessions you save will have this.

  • Oliver Salzburg

    You can use the very awesome 4bit Terminal Color Scheme Designer to generate a full color scheme for your shell.

    Just create a color scheme to your liking, then click the Get Scheme button and select putty.

    After downloading the .reg file, just import it to your registry to get the new color scheme. By default the registry change will only affect new sessions, but you can also apply the scheme to existing saved sessions by changing the last part of the path in the .reg file.