0% found this document useful (0 votes)
105 views1 page

Shell Conversion From Lower To Upper

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
105 views1 page

Shell Conversion From Lower To Upper

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Using & as Special replacement

character
Try the following command:
:1,$ s/Linux/&-Unix/p
3 substitutions on 3 lines
Rani my sister never uses Linux-Unix
:g/Linux-Unix/p
Linux-Unix is cooool.
Linux-Unix is now 10 years old.
Rani my sister never uses Linux-Unix
This command will replace, target pattern "Linux" with "Linux-Unix". & before -
Unix means use "last
pattern found" with given pattern, So here last pattern found is "Linux" which is
used with given -Unix
pattern (Finally constructing "Linux-Unix" substitute for "Linux").
Can you guess the output of this command?
:1,$ s/Linux-Unix/&Linux/p
Prev Home Next
Using range of characters in regular
expressions
Up Converting lowercase character to
uppercase
LSST v1.05 > Chapter 6 > Using & as Special replacement characte
http://www.cyberciti.biz/pdf/lsst/ch06sec10.html [7/29/2002 6:53:35 PM]
Linux Shell Scripting Tutorial (LSST) v1.05r3
Prev Chapter 6: Learning expressions with ex Next
Converting lowercase character to
uppercase
Try the following command
:1,$ s/[a-z]/\u &/g
Above command can be explained as follows:
Command Explanation
1,$ Line Address location is all i.e. find all lines for following pattern
s Substitute command
/[a-z]/ Find all lowercase letter - Target
\u&/
Substitute to Uppercase. \u& means substitute last patter (&) matched with its
UPPERCASE replacement (\u) Note: Use \l (small L) for lowercase character.
g Global replacement
Can you guess the output of following command?
:1,$ s/[A-Z]/\l&/g
Congratulation, for successfully completion of this tutorial of regular
expressions.
I hope so you have learn lot from this. To master the expression you have to do lot
of practice. This
tutorial is very important to continue with rest of tutorial and to become power
user of Linux. Impress
your friends with such expressions. Can you guess what last expression do?
:1,$ s/^ *$//
Note : indicates two black space.
Prev Home Next
Using & as Special replacement character Up awk - Revisited
LSST v1.05 > Chapter 6 > Converting lowercase character to uppercase
http://www.cyberciti.biz/pdf/lsst/ch06sec11.html [7/29/2002 6:53:37 PM]

You might also like