Linux Tips and Tricks

Linux Tips and Tricks

Lowercase to Uppercase in shell script and perl

September10

Shell Script

1
2
3
4
5
6
7
8
9
10
11
12
13
$ echo "abcd" | tr '[:lower:]' '[:upper:]'
ABCD
 
$ echo "Test Message" > ltou.txt
 
$ cat ltou.txt
Test Message
 
$ tr '[:lower:]' '[:upper:]' < ltou.txt
TEST MESSAGE
 
$ tr '[:upper:]' '[:lower:]' < ltou.txt
test message

Using Perl

1
2
3
4
5
6
7
8
$ echo "abcd" | perl -lane 'print uc($_);' 
ABCD 
 
$ perl -lane 'print uc($_);' ltou.txt 
TEST MESSAGE
 
$ perl -lane 'print lc($_);' ltou.txt
test message
posted under Uncategorized

Email will not be published

Website example

Your Comment:


Recent Comments

    Categories