- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script insertion
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
тАО06-08-2004 01:05 AM
тАО06-08-2004 01:05 AM
On HPUX ksh :
On a file,i want to transform string
xxxxxxxxxxxx
with ( insert .)
xxxx.xxxx.xxxx
Thanks a lot.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2004 01:12 AM
тАО06-08-2004 01:12 AM
Re: script insertion
cat filename | sed -e s/xxxxxxxxxxxx/xxxx.xxxx.xxxx/g > newfilename
John.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2004 01:14 AM
- Tags:
- sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2004 01:14 AM
тАО06-08-2004 01:14 AM
Re: script insertion
sed "s/xxxxxxxxxxxx/xxxx.xxxx.xxxx/" filename
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2004 01:19 AM
тАО06-08-2004 01:19 AM
Re: script insertion
1. open the file using vi
2. press : to go to command line.
3. enter command s/xxxxxxxxxxxx/xxxx.xxxx.xxxx/g
4. :wq!
to save and exit.
that's all.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2004 01:20 AM
тАО06-08-2004 01:20 AM
Re: script insertion
But there are lot of line
on my file , x is variable
i want to insert . every four caracters
here my file:
512df456rt89
789gfd18gf86
12fy56cd2296
789fy12hty89
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2004 01:21 AM
тАО06-08-2004 01:21 AM
Re: script insertion
This is a nasty way of doing it but it's all I can come up with at the moment.
STRING="123456789abcdefg";
a=`echo $STRING | cut -c1-4`
b=`echo $STRING | cut -c5-8`
c=`echo $STRING | cut -c9-12`
d=`echo $STRING | cut -c13-16`
echo "$a.$b.$c.$d"
- Tags:
- cut
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2004 01:26 AM
тАО06-08-2004 01:26 AM
Re: script insertion
Here's another nasty one (sorry Merijn) that does your whole file.
perl -ne '($a,$b,$c)=($_=~/^(....)(....)(....)/);print "$a.$b.$c\n"' datafile
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2004 01:36 AM
тАО06-08-2004 01:36 AM
Re: script insertion
Describe better what u need to subst, for instance:
# sed "s/^\(.\{4\}\)\(.\{4\}\)\(.\{4\}\)/\1.\2.\3/" < file1 > file2
would change the beginning of every line of file1 in that way, writing the new file file2
while
# sed "s/\(.\{4\}\)\(.\{4\}\)\(.\{4\}\)$/\1.\2.\3/" < file1 > file2
would change the ending part of every line of file1
If you need to change in the middle you must specify better the subst you need, even with some line of example
hope this helps
Cesare
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2004 01:45 AM
тАО06-08-2004 01:45 AM
Re: script insertion
# perl -pe 's/....(?:.)/$&$ENV{x}/g' your_file
512dfblah456rtblah89
789gfblahd18gfblah86
12fy5blah6cd22blah96
789fyblah12htyblah89
#
Maybe even clearer with
# env x=. perl -pe 's/....(?:.)/$&$ENV{x}/g' your_file
512df.456rt.89
789gf.d18gf.86
12fy5.6cd22.96
789fy.12hty.89
#
Enjoy, Have FUN!