changing all characters of a file to capital letters


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting changing all characters of a file to capital letters
# 1  
Old 09-29-2011
changing all characters of a file to capital letters

Hi guys.

I have file named output.txt containing file names. one per line. I use this command to convert all characters to capital letters and write to the same file.
Code:
cat output.txt | tr 'a-z' 'A-Z' > output.txt

But at the end output.txt is emtpy. Could anyone help??
# 2  
Old 09-29-2011
Code:
tr a-z A-Z < output.txt > _out &&
  mv -- _out output.txt

This User Gave Thanks to radoulov For This Post:
# 3  
Old 09-29-2011
Quote:
Originally Posted by radoulov
Code:
tr a-z A-Z < output.txt > _out &&
  mv -- _out output.txt

I Know the solution. I want to know why this occurs? Smilie
# 4  
Old 09-29-2011
Move o/p to temp file and mv it ..
Code:
$ tr -s '[:lower:]' '[:upper:]' < infile > dummy_file ; mv dummy_file infile

# 5  
Old 09-29-2011
Quote:
Originally Posted by majid.merkava
I Know the solution. I want to know why this occurs? Smilie
It happens because the redirection is performed before the rest of the operations Smilie
This User Gave Thanks to radoulov For This Post:
# 6  
Old 09-29-2011
Code:
perl -lane 'print uc($_)' inputfile > outputfile

# 7  
Old 09-29-2011
Quote:
Originally Posted by itkamaraj
Code:
perl -lane 'print uc($_)' inputfile > outputfile

Or:

Code:
perl -i -pe'$_ = uc' inputfile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Organizing text file by Capital Names (capital word ' ' capital word)

Hi I have a file passwd_exmpl that contains: root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync... (5 Replies)
Discussion started by: eladage
5 Replies

2. Solaris

Escape Sequence for Capital Letters Input at Shell Not Working

Hello, I am running Solaris 8. When issuing the command "stty lcase" all text which is output to the terminal are capitalized. Letters that are supposed to be capitals are preceded by a backslash during output. All text which is input is converted to lower case. This is the expected behaviour... (5 Replies)
Discussion started by: rstor
5 Replies

3. Shell Programming and Scripting

Put parentheses around all capital letters using SED

Hello everyone I tell you that I'm trying to do a bash program that can put parentheses around each capital letter of each line using SED. I tell you probe with: sed -e '1,$s/A/(A)/g' "$file" but only add parentheses in A. then tested with: sed 'y/AB/(A)(B)/' "$archivo" but it... (3 Replies)
Discussion started by: adiegorpc
3 Replies

4. Shell Programming and Scripting

changing 1st 3 characters of the file name!?

Hello Freinds, I have a file with name ABC123456. and I need to change this to X123456. Please tell me how can I do this? Thank you. (5 Replies)
Discussion started by: smarty86
5 Replies

5. Shell Programming and Scripting

Replace characters then read the file without changing it

Hi All At the moment the following code works but ideally i do not want to have to change the original $1 tr "\r" "\n" < "$1" > "$1.fix" printf "\n" >> "$1.fix" mv "$1.fix" "$1" FILE=$1 coffee_out="splitmovie" coffee_fill="-splitAt" coffee_end="-self-contained -o output.mov $2"... (1 Reply)
Discussion started by: babajuma
1 Replies

6. UNIX for Dummies Questions & Answers

How to search for capital letters

Hi, I just want to search a file for any words containng a capital letter and then display a list of just these words! I have been trying grep but to no has not helped.(im using the bash shell) (1 Reply)
Discussion started by: djdaniel3
1 Replies

7. Shell Programming and Scripting

change small letters to capital

hi guys, I know this might be very simple for u but not for me. I simply want to print the active users, changeing the first letter in their names to capital. i guess sed it's useful but don't know how to find the correspondign capital letter and don't know how to change just the first... (16 Replies)
Discussion started by: atticus
16 Replies

8. Shell Programming and Scripting

Change a parameter to be in capital letters

Hi, I have a korn shell script with 1 parameter. My script deletes certain files, for example.... sid=$1 rm $ORC/dbs/orapwd${sid} #orapwddb1 rm $ORC/dbs/lk${sid} #lkDB1 In the first file, the $sid must be in small letters and in the second file, the $sid must be in capital... (4 Replies)
Discussion started by: n8575
4 Replies

9. Shell Programming and Scripting

Changing Special Characters Using Sed

Hi. Does anyone know how to use the sed command to change the special border characters on this .per file. I have to edit about 80 .per files. I need a sed script to change the below 3 and A characters. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Test Islands, Office of Public Health -- WIC... (4 Replies)
Discussion started by: cstovall
4 Replies

10. UNIX for Dummies Questions & Answers

capital letters GONE!

I have an odd issue. I am trying to copy some files/folders to my linux box via a burned CD which I created on my mac. When I browse the files on the mac (or my windows box), everything looks fine (some of the folder names start with a capital letter, which is needed for everything to work... (8 Replies)
Discussion started by: blogg
8 Replies
Login or Register to Ask a Question