Hi I have a problem, I am attempting to write a bash script that goes through a file and can determine how many characters are at a set point in a line starting with QTY+113:100:PCE, If it detects 3 digits (number in bold) then pad it out with 12 zero's
If there are only two digits then pad it out with 13 zero's, also removing the + and : and adding the correct spacing if possible.
These numbers change, hence why I need it to detect how many characters
I need it to return
and if there are two numbers like
I need it to return
Any help would be greatly appreciated.
Last edited by firefox2k2; 07-21-2015 at 08:43 AM..
Could you please try following and let me know if this helps.
Output will be as follows.
For input with 2 digits as per your input it will be as follows.
Output will be as follows.
You haven't showed us the input file in first post of this thread, I have answered according to your question. Nevertheless you can try following. If following doesn't help you then kindly provide details as follows:
I- Your O.S name please.
II- Your input file how it looks an example with few data sample.
III- If above solutions are not working then show us errors which you are getting please.
Following code you can use may be helpful for you, also to appreciate anyone in this forum you can always push THANKS button present in below of any thread please.
You can give one file as for above code for testing purposes, if All is Well with above code then you can give as you are giving in your sample code shown.
Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
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)
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)
Hi,
I have written a script that returns the line number of the pattern i want and i stored the line number in a variable.Now i want to delete all the lines in a file above this line number which is stored in a variable.
i am using sed '1,$getlinenumberd' > file1.txt which is not working(wrog... (5 Replies)
Hi,
I have written a script that returns the line number of the pattern i want and i stored the line number in a variable(getlinenumber).Now i want to delete all the lines in a file above this line number which is stored in a variable.
i am using sed '1,$getlinenumberd' > file1.txt which is... (2 Replies)
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)
Hi,
I would like to know how do I print the line # in a script. My requirement is, I have a script which is about ~5000 lines long. If there are any errors happen I just exit. And I would like to add the line # of the script where the error happened.
Thanks, (6 Replies)
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)