- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: sed and tr
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2002 11:50 AM
09-13-2002 11:50 AM
a quick question, I'm using "tr" to change all capital letters in a file to small letters
cat textfile|tr [:upper:] [:lower:]
but when I try to do the same with "sed"
cat textfile|sed 's/[[:upper:]]/[[:lower:]]/'
it change all capital letters to string "[[:lower:]]", so how can we use sed for that.
PS. why [[:upper:]] in sed instead of [:upper:]
thanks
Gary
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2002 12:10 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2002 12:11 PM
09-13-2002 12:11 PM
Re: sed and tr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2002 12:13 PM
09-13-2002 12:13 PM
Re: sed and tr
If I did
sed -e 's/[123]/a/g'
Then that would replace either 1, 2, or 3 with "a".
Instead of 123 I use character class [:upper:]
sed -e 's/[[:upper:]]/a/g'
that would be the same as-
sed -e 's/[ABCDEFGHIJKLMNOPQRSTUVWXYZ]/a/g'
Which would replace all uppercase characters with "a". So using [[:lower:]] doesn't translate to the equivalent lower case character.
I hope that clarifies your question...
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2002 12:15 PM
09-13-2002 12:15 PM
Re: sed and tr
Yet another reason why Larry Wall wrote Perl:
perl -ne 'print lc()' textfile
Will print your file in all lower case.
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2002 12:21 PM
09-13-2002 12:21 PM
Re: sed and tr
Ted's way works(never used 'y' function before).
thanks Rodney for the clarification. BTW, the example sed -e 's/[123]/a/g' , shouldn't it be [1|2|3]
Gary
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2002 12:24 PM
09-13-2002 12:24 PM
Re: sed and tr
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2002 06:37 AM
09-16-2002 06:37 AM
Re: sed and tr
[:lower:] and friends and perl's uc () and lc () functions also take LOCALE settings into consideration, and are portable to EBCDIC character sets where [a-z] and [A-Z] will fail
As side note 2
probably becoming a peeve pet, but why the h**l do all those examples include the cat command? Is it a hobby to fill the system's process space, or are people still not told enough that unix is based on pipes and redirects are the way to go?
# perl -pe'$_=lc' textfile
will do what you want fast and reliable