- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script help, text file, replace and insert a retur...
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
Discussions
Discussions
Forums
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
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
тАО02-23-2004 12:20 PM
тАО02-23-2004 12:20 PM
to simplify it I made an example : abcd'efg'hijkl'mn'opqrs'tuv'
how can I change it to like following:
1) delete " ' " and at the point start another line, output is :
abcd
efg
hijkl
mn
opqrs
tuv
2) start another line after every 3 " ' " charactors, leave " ' " there.
abcd'efg'hijkl'
mn'opqrs'tuv'
I need unix script to do it, thank you for any help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2004 01:59 PM
тАО02-23-2004 01:59 PM
Re: script help, text file, replace and insert a return
You can do this with perl. I'm learning this also so have taken the opportunity
For your first method
#-----------------------------------
#!/usr/bin/perl -w
open (MYFILE, "sourcefile") || die "$!";
open (NEWFILE, ">>destination")
while
@newarray=(split (/'/, $_));
foreach $new (0..$#newarray) {
print NEWFILE "newarray[$new]\n";
}
}
close MYFILE;
close NEWFILE;
#--------------------------
Will post second method when I work it out
HTH
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2004 02:35 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2004 02:50 PM
тАО02-23-2004 02:50 PM
Re: script help, text file, replace and insert a return
nice, curt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2004 03:03 PM
тАО02-23-2004 03:03 PM
Re: script help, text file, replace and insert a return
cat file | tr "'" "\012" |
awk '{
x++;
if ( x == 3 ) {
printf("$s\047\n",$0);
x=0;
}else{
printf("%s\047",$0);
}}
END {
if ( x < 3 ) printf("\n");
}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2004 03:26 PM
тАО02-23-2004 03:26 PM
Re: script help, text file, replace and insert a return
cat file | myPerl.pl
or
myPerl.pl fileName
myPerl.pl contains:
#!/opt/perl/bin/perl -w
while (<>) {
tr/'/\n/;
print;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2004 03:42 PM
тАО02-23-2004 03:42 PM
Re: script help, text file, replace and insert a return
cat file | myPerl.pl
or
myPerl.pl fileName
myPerl.pl contains:
#!/opt/perl/bin/perl -w
while (<>) {
s/([^']*'[^']*'[^']*')/$1\n/g;
print;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2004 04:26 PM
тАО02-23-2004 04:26 PM
Re: script help, text file, replace and insert a return
but curt,
the output for 2) is not very correct
should be
abcd'efg'hijkl'
mn'opqrs'tuv'
real output is
abcd'efg'$s'
mn'opqrs'$s'
So I think the script should be
2)
cat file | tr "'" "\012" |
awk '{
x++;
if ( x == 3 ) {
printf("%s\047\n",$0); * change $ to % here.
x=0;
}else{
printf("%s\047",$0);
}}
END {
if ( x < 3 ) printf("\n");
}'
thank you, it help me alot!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2004 05:55 PM
тАО02-23-2004 05:55 PM
Re: script help, text file, replace and insert a return
lt09:/tmp 120 > cat xx.txt
abcd'efg'hijkl'mn'opqrs'tuv'
abcd'efg'hijkl'mn'opqrs'
abcd'efg'hijkl'mn'opqrs
abcd'efg'hijkl'mn'
lt09:/tmp 121 > perl -pe's/([^'"']+'"'){3}(?=.)/$&\n/g' xx.txt
abcd'efg'hijkl'
mn'opqrs'tuv'
abcd'efg'hijkl'
mn'opqrs'
abcd'efg'hijkl'
mn'opqrs
abcd'efg'hijkl'
mn'
lt09:/tmp 122 >
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2004 09:43 PM
тАО02-23-2004 09:43 PM