- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to insert a New Line for every occurance of th...
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
01-07-2004 02:26 AM
01-07-2004 02:26 AM
UNB+UNOA:2+AISUPP+AIHUB+040107:1300+AISPAIHB009329++INVOIC'UNG+INVOIC+AISUPP+AIHUB+040107:1300+877+UN+D:96A:EAN008'UNH+1+INVOIC:D:96A:UN:EAN008'
I need the above as follows:
UNB+UNOA:2+AISUPP+AIHUB+040107:1300+AISPAIHB009329++INVOIC'
UNG+INVOIC+AISUPP+AIHUB+040107:1300+877+UN+D:96A:EAN008'
UNH+1+INVOIC:D:96A:UN:EAN008'
Anyone any ideas as to how this can be done..?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2004 02:32 AM
01-07-2004 02:32 AM
Re: How to insert a New Line for every occurance of the ' char?
open the file in vi
:%s:':'^M:g
where the chars between 3 and 4th colons are
'
HTH,
Umapathy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2004 02:33 AM
01-07-2004 02:33 AM
Re: How to insert a New Line for every occurance of the ' char?
cat file | awk '{ gsub("'"'"'","'"'"'\n"); print }'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2004 02:38 AM
01-07-2004 02:38 AM
Re: How to insert a New Line for every occurance of the ' char?
and if you want to change the file
# perl -pi -e's/\x27/\n/g' your_file
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2004 02:41 AM
01-07-2004 02:41 AM
Re: How to insert a New Line for every occurance of the ' char?
tr -s "'" "[\012*]" file_name
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2004 02:50 AM
01-07-2004 02:50 AM
Re: How to insert a New Line for every occurance of the ' char?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2004 03:03 AM
01-07-2004 03:03 AM
Re: How to insert a New Line for every occurance of the ' char?
my 2 cents:
BEGIN{}
{
for (i = 1; i < NF; i++) printf("%s'\n", $i);
printf("%s\n", $NF);
}
END{}
call awk -F\' file
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2004 03:07 AM
01-07-2004 03:07 AM
Re: How to insert a New Line for every occurance of the ' char?
awk -F"'" '{for (i=1;i
-- Graham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2004 03:44 AM
01-07-2004 03:44 AM
Re: How to insert a New Line for every occurance of the ' char?
Procura your perl script seems to work best but doesn't keep the ' which isn't a big deal. The other e.g's which used awk seemed to fail because of the following:
awk: Input line UNB+UNOA:2+AISUPP+AI cannot be longer than 3,000 bytes.
The source line number is 1.
If you have an idea to keep the ' that would be brilliant. Tks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2004 04:03 AM
01-07-2004 04:03 AM
SolutionI use \x27 as a way to write a single quote in a shell one-liner.
if this is inside a script, you can just use
--8<---
#!/opt/perl/bin/perl
use strict;
use warnings;
while (<>) {
s/'/'\n/g;
print;
}
-->8---
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2004 04:16 AM
01-07-2004 04:16 AM
Re: How to insert a New Line for every occurance of the ' char?
this may also work:
/'/{
s/'/'\
/g
}
put it in a file and call with:
sed -f yourfile.sed yourfile
have fun,
Michael