- Community Home
- >
- Servers and Operating Systems
- >
- Operating System - Linux
- >
- General
- >
- Quick grep format question
-
- Forums
-
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
- HPE Blog, Austria, Germany & Switzerland
- Blog HPE, France
- HPE Blog, Italy
- HPE Blog, Japan
- HPE Blog, Middle East
- HPE Blog, Latin America
- HPE Blog, Russia
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
-
Blogs
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Blog, Latin America
- HPE Blog, Middle East
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
-
Information
- Community
- Welcome
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Tips and Tricks
- Resources
- Announcements
- Email us
- Feedback
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Aruba Airheads Community
- Enterprise.nxt
- HPE Dev Community
- Cloud28+ Community
- Marketplace
-
Forums
-
Blogs
-
Information
-
English
- 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
- Email to a Friend
- Report Inappropriate Content
11-14-2001 04:54 AM
11-14-2001 04:54 AM
I want to use grep to copy all the words in a file which have uppercase letters into another file.
I just want the uppercase words themselves, not the entire line.
Can someone give me the command?
I'd appreciate it.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-14-2001 05:39 AM
11-14-2001 05:39 AM
Solutionwhile(<>) {
chomp;
foreach $word (split) {
if ($word=~/^[A-Z]+/) { print $word,"\n"; }
}
}
then run it:
perl script.pl yourfile > resultfile
resultfile will contain all words from yourfile starting with an uppercase letter, one word per line. If you want only all-uppercase words, add $ after + and if you want uppercase anywhere in the word, remove ^.
HTH,
Marcin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-14-2001 07:32 AM
11-14-2001 07:32 AM
Re: Quick grep format question
here a solution without perl:
# cat bastel.sh
action()
{
while [ $# -gt 0 ]
do
echo $1 | grep -e '[A-Z]'
shift
done
}
while read LINE
do
action $LINE
done
#
Volker
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-21-2001 07:56 PM
11-21-2001 07:56 PM
Re: Quick grep format question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-22-2001 03:18 AM
11-22-2001 03:18 AM
Re: Quick grep format question
---------------------------
echo inputfile | awk 'BEGIN { RS="[\ \t]"} { print $1 }' | grep ^[A-Z] > outputfile
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2021 Hewlett Packard Enterprise Development LP