Sponsored Content
Top Forums Shell Programming and Scripting Masking Bank Account Number except last 4 digits in the file Post 303023071 by Pradeep R on Tuesday 11th of September 2018 09:49:27 AM
Old 09-11-2018
I know how to do it in Oracle (like below), however client need in shell script.
Code:
select length('520114025017'),
                  '520114025017'  bank_account_number,      
 lpad(substr('520114025017',length('520114025017')-3,length('520114025017')),9,'X')
          from dual;

Thanks,
Pradeep

Last edited by Scott; 09-11-2018 at 04:28 PM.. Reason: ICODE to CODE tags
 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

restrain the number of digits of a PID

How is it possible under UNIX to restrain the number of digits of the PID number? For instance, we have a product that generates a PID of 7 digits, and we would like to have only 6 digits maximum instead for the PID. Thank you for your help. (1 Reply)
Discussion started by: mlefebvr
1 Replies

2. Shell Programming and Scripting

Count number of digits in a word

Hi all Can anybody suggest me, how to get the count of digits in a word I tried WORD=abcd1234 echo $WORD | grep -oE ] | wc -l 4 It works in bash command line, but not in scripts :mad: (12 Replies)
Discussion started by: ./hari.sh
12 Replies

3. Emergency UNIX and Linux Support

Masking of number

BAT:0310:2009-08-0:Y4 :H:D:00003721:03103721.IFH:00138770:05767:00000000001279' EXR:CLP:912.570000' STA:A:9071559:2009-08-10::Wer::Mrs' DEF::531.97:531.97:310221661617::+ABC:BAL:1:N::::5:40.00:0.00:2009-08-10:CN:1111111111109962::3:N:missc :N:PH:00010833:... (5 Replies)
Discussion started by: mad_man12
5 Replies

4. Shell Programming and Scripting

number of digits after decimal

Hi All, I have a file of decimal numbers, cat file1.txt 1.1382666907 1.2603107334 1.6118799297 24.4995857056 494.7632588468 560.7633734425 ..... I want to see the output as only 7 digits after decimal (5 Replies)
Discussion started by: senayasma
5 Replies

5. Shell Programming and Scripting

summing the digits of a binary nuMBER

please help me write a perl program to find the difference of 1 and zeros of a 6 digit binary number. eg If input is 111100 expected output +2 if input is 000011 expected output -2 input is 000111 expected output 0 (2 Replies)
Discussion started by: dll_fpga
2 Replies

6. Shell Programming and Scripting

extracting Number variable and the following digits.

HI all, I have output of something like this: crab: ExitCodes Summary >>>>>>>>> 12 Jobs with Wrapper Exit Code : 50117 List of jobs: 1-12 See https:///twiki/something/ for Exit Code meaning crab: ExitCodes Summary >>>>>>>>> 5 Jobs with Wrapper Exit Code : 8001 List of... (20 Replies)
Discussion started by: emily
20 Replies

7. Shell Programming and Scripting

awk changes to cut number of digits

HCPM1ONDB00014800011800000589009211201 L201307022013070228AUD 00000000031. 000965105800000000000000000000000 MOBITV KEYA ... (4 Replies)
Discussion started by: mirwasim
4 Replies

8. Shell Programming and Scripting

Find number of digits in a word

HI, Can you tell me how to find the number of digits in a word. $cat data.txt +123456ad 87645768 Output should be 6 8 (5 Replies)
Discussion started by: ashwin3086
5 Replies

9. Post Here to Contact Site Administrators and Moderators

Verify from one account number to another account number

Hi, Can anyone suggest me for the below steps. Here the index files is nothing but a text file and In index file there are n number of pdf files. Step 0 check out if this is for A(index file) or B(index file) 1. Read the first line of the original index file 2. Read the 9th character... (1 Reply)
Discussion started by: pavand
1 Replies
DBIx::Class::Helper::Row::OnColumnChange(3pm)		User Contributed Perl Documentation	     DBIx::Class::Helper::Row::OnColumnChange(3pm)

NAME
DBIx::Class::Helper::Row::OnColumnChange - Do things when the values of a column change VERSION
version 2.013002 SYNOPSIS
package MyApp::Schema::Result::Account; use parent 'DBIx::Class::Core'; __PACKAGE__->load_components(qw(Helper::Row::OnColumnChange)); __PACKAGE__->table('Account'); __PACKAGE__->add_columns( id => { data_type => 'integer', is_auto_increment => 1, }, amount => { data_type => 'float', keep_storage_value => 1, }, ); __PACKAGE__->before_column_change( amount => { method => 'bank_transfer', txn_wrap => 1, } ); sub bank_transfer { my ($self, $old_value, $new_value) = @_; my $delta = abs($old_value - $new_value); if ($old_value < $new_value) { Bank->subtract($delta) } else { Bank->add($delta) } } 1; or with DBIx::Class::Candy: package MyApp::Schema::Result::Account; use DBIx::Class::Candy -components => ['Helper::Row::OnColumnChange']; table 'Account'; column id => { data_type => 'integer', is_auto_increment => 1, }; column amount => { data_type => 'float', keep_storage_value => 1, }; before_column_change amount => { method => 'bank_transfer', txn_wrap => 1, }; sub bank_transfer { my ($self, $old_value, $new_value) = @_; my $delta = abs($old_value - $new_value); if ($old_value < $new_value) { Bank->subtract($delta) } else { Bank->add($delta) } } 1; DESCRIPTION
This module codifies a pattern that I've used in a number of projects, namely that of doing something when a column changes it's value in the database. It leverages DBIx::Class::Helper::Row::StorageValues for passing in the $old_value, which do not have to use. If you leave the "keep_storage_value" out of the column definition it will just pass "undef" in as the $old_value. Also note the "txn_wrap" option. This allows you to specify that you want the call to "update" and the call to the method you requested to be wrapped in a transaction. If you end up calling more than one method due to multple column change methods and more than one specify "txn_wrap" it will still only wrap once. I've gone to great lengths to ensure that order is preserved, so "before" and "around" changes are called in order of definition and "after" changes are called in reverse order. To be clear, the change methods only get called if the value will be changed after "update" runs. It correctly looks at the current value of the column as well as the arguments passed to "update". METHODS
before_column_change __PACKAGE__->before_column_change( col_name => { method => 'method', # <-- anything that can be called as a method txn_wrap => 1, # <-- true if you want it to be wrapped in a txn } ); Note: the arguments passed to "method" will be "$self, $old_value, $new_value". after_column_change __PACKAGE__->after_column_change( col_name => { method => 'method', # <-- anything that can be called as a method txn_wrap => 1, # <-- true if you want it to be wrapped in a txn } ); Note: the arguments passed to "method" will be "$self, $old_value, $new_value". around_column_change __PACKAGE__->around_column_change( col_name => { method => 'method', # <-- anything that can be called as a method txn_wrap => 1, # <-- true if you want it to be wrapped in a txn } ); Note: the arguments passed to "method" will be "$self, $next, $old_value, $new_value". Around is subtly different than the other two callbacks. You must call $next in your method or it will not work at all. A silly example of how this is done could be: sub around_change_name { my ($self, $next, $old, $new) = @_; my $govt_records = $self->govt_records; $next->(); $govt_records->update({ name => $new }); } Note: the above code implies a weird database schema. I haven't actually seen a time when I've needed around yet, but it seems like there is a use-case. Also Note: you don't get to change the args to $next. If you think you should be able to, you probably don't understand what this component is for. That or you know something I don't (equally likely.) CANDY EXPORTS
If used in conjunction with DBIx::Class::Candy this component will export: before_column_change around_column_change after_column_change AUTHOR
Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com> COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Arthur Axel "fREW" Schmidt. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-06-18 DBIx::Class::Helper::Row::OnColumnChange(3pm)
All times are GMT -4. The time now is 10:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy