- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: data manipulation in the file
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
тАО03-12-2007 10:52 PM
тАО03-12-2007 10:52 PM
I want the 5th,6th and 7th character in a file to be replaced by a string
Can anybody help me??
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2007 11:01 PM
тАО03-12-2007 11:01 PM
Re: data manipulation in the file
and welcome to the forums !
What do you mean by "without opening" ?
In order to read the data you have to open the file!
You can read this earlier thread with a similar problem:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1107862
Please also read:
http://forums1.itrc.hp.com/service/forums/helptips.do?#33 on how to reward any useful answers given to your questions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2007 11:09 PM
тАО03-12-2007 11:09 PM
Re: data manipulation in the file
Thank u so much for the welcum
and bout the query..
the link dint help.
here i dont know wat these 5th, 6th and 7th characters are, i just want them replaced
and what i meant by saying without opening the file is that, if u open a file in any editor, its not a prob to replace a character
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2007 11:20 PM
тАО03-12-2007 11:20 PM
Re: data manipulation in the file
if you want to change 5-7 char of each line:
perl -ple 'substr($_,4,3,"abc")' g.lis > h.lis
Example:
input (g.lis)
12399456
12398456
output (h.lis)
1239abc6
1239abc6
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2007 11:28 PM
тАО03-12-2007 11:28 PM
Re: data manipulation in the file
or if you only want this to happen on the first line of the file:
perl -ple 'substr($_,4,3,"abc") if $.==1' g.lis > h.lis
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2007 11:33 PM
тАО03-12-2007 11:33 PM
Re: data manipulation in the file
am really sorry.. i forgot to say i need the solution in shell scripting terms..
since i dont understand perl.
pls
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2007 11:43 PM
тАО03-12-2007 11:43 PM
Re: data manipulation in the file
in that case the whole things gets a bit more complex. Can you please provide an example line of input, as we need to know if the data is split into fields etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2007 11:54 PM
- Tags:
- sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2007 11:59 PM
тАО03-12-2007 11:59 PM
Re: data manipulation in the file
if sed is ok by you, could you please complete the thread by awarding points to helpful answers and summarising the solution for you. Otherwise please continue the thread.
http://forums1.itrc.hp.com/service/forums/helptips.do?#33 shows how to reward any useful answers given to your questions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-13-2007 12:37 AM
тАО03-13-2007 12:37 AM
Re: data manipulation in the file
When you use those shell redirections, as shown, the shell is doing the opening (and possibly clobbering) for you by system calls behind the scenes.
You could verify by attaching a syscall tracer like tusc, truss, or strace to your processes...