- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Adding column
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-19-2008 02:54 AM
тАО06-19-2008 02:54 AM
0364120000013502000117186270*805
0323120000013502200115594152*805
0438120000013502400107398174*805
0364120000013502500106634595*805
i need the o/p file
03641200000135*02000117186270*805
03231200000135*02200115594152*805
04381200000135*02400107398174*805
03641200000135*02500106634595*805
I tried sed command but unable to do it.
Thanks in Advanced.
Solved! Go to Solution.
- Tags:
- sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-19-2008 03:49 AM
тАО06-19-2008 03:49 AM
Re: Adding column
One way:
# perl -pe 's/(.{13})/$1\*/' file
...and if you want to update in-place do:
# perl -pi -e 's/(.{13})/$1\*/' file
Note that Perl counts from zero, so the fisrt column is 0.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-19-2008 03:58 AM
тАО06-19-2008 03:58 AM
Re: Adding column
Oops, I can't count:
# perl -pe 's/(.{14})/$1\*/' file
# perl -pi -e 's/(.{14})/$1\*/' file
...to update inplace
(or):
sed -e 's/\(.\{14\}\)/\1\*/' file
...as the firt Perl's counterpart.
Regards!
...JRF...
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-19-2008 04:06 AM
тАО06-19-2008 04:06 AM
Re: Adding column
do
e=${b#???}
eval "f=${b%$e}"
echo $a $f\*$e
done
or
awk '{printf("%s %s*%s\n", $1, substr($2,1,3),substr($2,4)) }'
of if it is always 135
while read a b c
do
e=${b#135}
echo $a 135\*$e
done
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-19-2008 05:24 AM
тАО06-19-2008 05:24 AM
Re: Adding column
0364120000013502000117186270*805
0323120000013502200115594152*805
0438120000013502400107398174*805
0364120000013502500106634595*805
td192> < n.dat sed -e 's/^\(..............\)/\1*/'
03641200000135*02000117186270*805
03231200000135*02200115594152*805
04381200000135*02400107398174*805
03641200000135*02500106634595*805
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-19-2008 05:49 AM
тАО06-19-2008 05:49 AM
Re: Adding column
Now how to remove the added * from Outfile to get initial file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-19-2008 05:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-19-2008 05:58 AM
тАО06-19-2008 05:58 AM
Re: Adding column
> The sed command (sed -e 's/\(.\{14\}\)/\1\*/' file) is working fine.
> Now how to remove the added * from Outfile to get initial file
Then:
# sed -e 's/\*//' file
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2008 03:16 AM
тАО06-20-2008 03:16 AM