- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Problem in out of greping.
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
12-12-2007 09:48 PM
12-12-2007 09:48 PM
I am having one .dat file(MEMBER_ALL.dat) which having entries like:
"DMNH01-03-200710:10:59666682229 MID MMEDSCZFHI1234567999hgjnrfoodoJrGF kxzgF Y I 7546713742B Y 16-04-1940 01-12-200615-12-2006RAMYY U14-11-2005Y BY000050000000040000 123456789 1C NABIPW987654321987001 DM24100005"
this is complete 1 line. Similarly he is having sevral lines.
What i am doing is like..
while read line
do
refkey=`echo "$line" | cut -c1-2`
if [ "$refkey" = "DM" ]; then
echo $line | grep $refkey >> DM.dat
fi;
done
Basically it will cut first 2 char and then redirect the complete line in other .dat file.
But when i see the output it is suppressing the spaces between two vaules. I want exact line what is present in input file(MEMBER_ALL).
Can anyone suggest how to do this?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2007 12:11 AM
12-13-2007 12:11 AM
Re: Problem in out of greping.
$ grep ^DM MEMBER_ALL > DM.dat
With your "if", this line will always match:
echo $line | grep $refkey
And is the same as:
echo $line
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2007 12:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2007 12:19 AM
12-13-2007 12:19 AM
Re: Problem in out of greping.
just replace echo $line by echo "$line".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2007 12:31 AM
12-13-2007 12:31 AM
Re: Problem in out of greping.
You're right. It wasn't the read but the echo.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2007 12:34 AM
12-13-2007 12:34 AM
Re: Problem in out of greping.
# grep ^\"DM MEMBER_ALL.dat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2007 12:56 AM
12-13-2007 12:56 AM
Re: Problem in out of greping.
Since Gopal is getting some output, those "" must not really be there in the file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2007 01:48 AM
12-13-2007 01:48 AM
Re: Problem in out of greping.
Very much for your replies. Thanks to Dennis and Laurent's.
This statement is working for me.
grep "^DM" MEMBER_ALL >DM.dat
Thanks