- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: text processing
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
07-29-2004 11:12 PM
07-29-2004 11:12 PM
NWDEMSGTYPESEQ
NWDEMSGCTRYTIME
File 2:
NWDE-MSG-TYPE-SEQ
NWDE-MSG-CTRY-TIME
Now I need a output like
echo else if (name.equalsIgnoreCase("
{
setNWDEMSGTYPESEQ(strBuff);
}
I would like to loop to get a output somewhat like
echo else if (name.equalsIgnoreCase("NWDE-MSG-TYPE-SEQ"))
{
set(strBuff);
}
quick 10 points!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2004 11:37 PM
07-29-2004 11:37 PM
Re: text processing
echo else if (name.equalsIgnoreCase("NWDE-MSG-TYPE-SEQ"))
{
setNWDEMSGTYPESEQ(strBuff);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2004 11:50 PM
07-29-2004 11:50 PM
Re: text processing
echo "echo else if(name.equalsIgnoreCase(\"$(tail -1 file2)\"))\n{\nset$(head -1 file1)(strBuff);\n}"
printf "echo else if(name.equalsIgnoreCase(\"$(tail -1 file2)\"))\n{\nset$(head -1 file1)(strBuff);\n}"
Delemit " character with \
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2004 02:13 AM
07-30-2004 02:13 AM
Re: text processing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2004 02:18 AM
07-30-2004 02:18 AM
Re: text processing
If you just have plain text files, and rephrase the question, you might have more luck here with people knowing to do what you want in awk/sed/perl/sh
Enjoy, Have FUN! H.Merijn [ who honoustly has no idea what to answer to the original question ]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2004 02:37 AM
07-30-2004 02:37 AM
Re: text processing
$>perl
$fd1="file1";
$fd2="file2";
open fd1;
open fd2;
while (
$File1Line=$_;
$File2Line=$_;
$File1Line=~ s/\n//g;
$File2Line=~ s/\n//g;
print "echo else if (name.equalsIgnoreCase(\"$File2Line\"))\n";
print "{\n";
print "set$File1Line(strBuff);\n";
print "}\n";
}
It outputs this from your original files :
echo else if (name.equalsIgnoreCase("NWDEMSGTYPESEQ"))
{
setNWDEMSGTYPESEQ(strBuff);
}
echo else if (name.equalsIgnoreCase("NWDEMSGCTRYTIME"))
{
setNWDEMSGCTRYTIME(strBuff);
}
Regards,
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2004 02:54 AM
07-30-2004 02:54 AM
Re: text processing
It is as simple as,
awk '{ print "else if(name.equalsIgnoreCase(\""$0"))\n{\nsetNWDEMSGTYPESEQ(strBuff);" }'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2004 03:26 AM
07-30-2004 03:26 AM
Re: text processing
modified as,
awk '{ print "else if(name.equalsIgnoreCase(\""$0"))\n{\nsetNWDEMSGTYPESEQ(strBuff);\n}" }' file1
Output:
=======
else if(name.equalsIgnoreCase("NWDEMSGTYPESEQ))
{
setNWDEMSGTYPESEQ(strBuff);
}
else if(name.equalsIgnoreCase("NWDEMSGCTRYTIME))
{
setNWDEMSGTYPESEQ(strBuff);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2004 04:06 AM
07-30-2004 04:06 AM
Re: text processing
Regards,
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2004 04:34 AM
07-30-2004 04:34 AM
Solutionpr -mt file1 file2 | perl -n -e 'chomp; ($a,$b)=split "\\s+"; print "echo else if (name.equalsIgnoreCase(\"${b}\"))\n{\nset$
{a}(strBuff);\n}\n"'
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2004 05:38 AM
07-30-2004 05:38 AM
Re: text processing
Perl:
perl -p -e 's/[^.]/else if(name.equalsIgnoreCase(\"/;s/$/\"))\n{\nsetNWDEMSGTYPESEQ(strBuff);\n}/' file*
To put the modified contents in the same file then,
perl -p -i -e 's/[^.]/else if(name.equalsIgnoreCase(\"/;s/$/\"))\n{\nsetNWDEMSGTYPESEQ(strBuff);\n}/' file*
Using sed:
sed -e 's/[^.]/else if(name.equalsIgnoreCase(\"/;s/$/\"))\
{\
setNWDEMSGTYPESEQ(strBuff);\
}/p' file*
Regards
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2004 01:31 PM
08-01-2004 01:31 PM
Re: text processing
So you are trying to generate a long shell script driven by two list of words that are garantueed to remain in sync?
If the first file always a simple transformation of the second by removing all dashes? In that case I'd just use the second file with a 'one liner' like:
perl -pe 'chomp;$x=$_;s/-//g;$y=$_;$_="echo else if name.equalsIgnoreCase(\"$x\")\n{\n\set$y(strBuff);\n}\n"' file_2
(save word in x, remove dashes; save new word in y, create print buffer, let perl do the loop - read - print. )
If you need the two files, then I like the 'pr' solution as long as they remain in sync. If not you'll just need a doubel read loop. Some variation on the following awk 'one liner':
awk '{getline y < "file_1";print "echo else if name.equalsIgnoreCase(\"" $1 "\")\n{\nset" y "(strBuff);\n}\n"}' file_2
Cheers,
Hein.