i have a requirement where in a file i will get string. The length could be from 1 to 20. if the string is less than 6 characters ( ex: ABCD) . i need to append 'X' on right hand side to make it 6 characters (ex: ABCDXX). if suppose i get the same string from the file as ABCDXX then i should not touch this string, where as i need to append one more X to the original ABCD to make it ABCDXXX and again i need to search if ABCDXXX again exists in the file. if it exists again i should not touch that string in the file where as i need to append ABCDXXXX to make it distinct and this will continue.
Here is example in the File.
in the above case we have 3 ABCDXX strings after conversion. to make it unique
in the above case ABCD--ABCDXX--ABCDXXX should be converted like this.
ABCDXX-- from the file should not be touched as it satisfies the 6 character condition
and ABCDX--ABCDXX--ABCDXXXX should be converted like this.
this is how the final file will look like
Please help me with the logic
Thanks
dsdev
Last edited by radoulov; 07-28-2011 at 05:00 PM..
Reason: Code tags!
sorry to ask this again
in the input file i have 2 columns and the logic should be applied on col2 and the 2 columns are separated by comma in the input file.The outfile should have 2 columns in the file and 3rd derived column separated by comma.
Code:
input file
outputfile
1,ABC
1,ABC, ABCXXXX
2,ABCD
2,ABCD,ABCDXXXXX
3,ABCDX
3,ABCDX,ABCDXXXXXX
4,ABCDXX
4,ABCDXX,ABCDXX
5,ABCDXXX
5,ABCDXXX,ABCDXXX
6,ABCDXXXX
6,ABCDXXXX,ABCDXXXX
7,ABCXXX
7,ABCXXX,ABCXXX
8,A
8,A,AXXXXX
9,B
9,B,BXXXXX
Thanks again
dsdev
Last edited by dsdev_123; 07-29-2011 at 04:30 PM..
Reason: Code tags.
Having trouble with the logic when looping over this switch case again:
for (j = 0; data != 0; j++){
switch(data){
case 'c':
output = ranit(r_brace_array);
break;
case 'h':
output = ranit(pipe_array);
break;
... (6 Replies)
I need to implement a looping logic.
If then
Go to /path1/file*
Get all the filename starting with file* and store it in a array
count file number and store it in variable like run
Ex: I found 3 file with starting file* so my run = 3
means my loop should run three time
May be... (1 Reply)
Hi All
I have a requirement to find the file that are most latest to be modified in each directory. Can somebody help with the command please?
E.g of the problem.
The directory A is having sub directory which are having subdirectory an so on.
I need a command which will find the... (2 Replies)
hi;
i need a script which will go to all directories and subdirectories and print the filenames as follow;
here i m printing only files listing in current directory
reason i m doing this is coz i want to perform some operations according to filename achieved so cant use find command;... (4 Replies)
Hi All,
Are there any logic to extract the only lines between first two *TM* (which is marked in blue)?
VOL1HST99 0
HDR1A999999S 999999HST99
HDR2F001200012001
UHL1 0729609000001 000000
*TM*^^^^^^^^^^^^^^^^^^^^^^
01012610252171017301805000... (2 Replies)