Real quick and easy, I just need to drop it here as I was using it most of the times handling tens of thousand keyword text files.
If you need to convert the first letter of the word or first letter of a text line to its uppercase, read on.
Here's how to convert the first letter of a word from text files.
Say, we have thousands of text lines like
# cat testfile.txt
~~~~~~~~~~~~~~~~~~~~~~~~~
linux blog
sysad linux blog
systems admin blog
linux blogs
fedora blog
foss
gnu
...
...
gnome
redhat blog
linux blogging
~~~~~~~~~~~~~~~~~~~~~~~~~
and we wish to convert all first letters of each lines to its uppercase letter or capitalized form.
Am going to approach this using one of the powerful command-line drive linux tool called sed. Here's how it can be simply done.
# cat testfile.txt | sed -e 's/\(.\)\(.*\)/\u\1\2/'
Alternatively,
# sed -e 's/\(.\)\(.*\)/\u\1\2/' testfile.txt
which gives you a similar output like so
~~~~~~~~~~~~~~~~~~~~~~~~~
Linux blog
Sysad linux blog
Systems admin blog
Linux blogs
Fedora blog
Foss
Gnu
Gnome
Redhat blog
Linux blogging
~~~~~~~~~~~~~~~~~~~~~~~~~
Hope this helps, enjoy!
Some Articles
Why Choose Fedora over Ubuntu?
Fedora vs RHEL
Subscription
Categories
- HowTos (612)
- Linux Devices (40)
- Linux Diggs (620)
- Linux News (1541)
- Linux Videos (24)
Recent Posts
Blog Archive
-
▼
2008
(2301)
-
▼
March
(8)
- Shell: Shortcut To Last Command Line Argument
- HowTo: Motion Picture Linux Paint and Retouching Tool
- HowTo: Convert First Letter of Dir Folder to Upper...
- HowTo: Lightning Speed Big Claws
- HowTo: Convert First Letter of Text Line to Uppercase
- HowTo: Automatically Change your Fedora Desktop Wa...
- HowTo: Extremely Powerful Linux Password Sniffer
- HowTo: Recover Missing Portmap on Fedora 8
-
▼
March
(8)
Tuesday, March 11, 2008
HowTo: Convert First Letter of Text Line to Uppercase
Subscribe to:
Post Comments (Atom)
ILoveTux - howtos and news | About | Contact | TOS | Policy
0 comments:
Post a Comment