Sponsored Content
Top Forums Shell Programming and Scripting Bash detecting number of digits in line Post 302950140 by firefox2k2 on Tuesday 21st of July 2015 10:15:22 AM
Old 07-21-2015
Quote:
Originally Posted by rbatte1
How is the important number generated? If it is in a shell script, you can use typeset -Z15 variable to automatically pad it, if that helps.

Can you tell us more about the overall process? There may be a better solution.


Robin

Hi Robin, below is an example of the original text file I am starting with, the numbers are an order quantity, they can be anything from 0 to 100's:

Code:
DTM+64:20160601:102'
DTM+63:20160630:102'
QTY+113:50:PCE'
SCC+4'
DTM+64:20160701:102'
DTM+63:20160731:102'
QTY+113:50:PCE'
SCC+4'
DTM+64:20160801:102'
DTM+63:20160831:102'
QTY+113:0:PCE'
SCC+4'
DTM+64:20160901:102'
DTM+63:20160930:102'
QTY+113:50:PCE'
SCC+4'
DTM+64:20161001:102'
DTM+63:20161031:102'
QTY+113:0:PCE'
SCC+4'
DTM+64:20161101:102'
DTM+63:20161130:102'

I need it to look like this :

Code:
DTM07 64 20160601                           102
DTM07 63 20160630                           102
QTY   113000000000000050PCE4  
DTM07 64 20160701                           102
DTM07 63 20160731                           102
QTY   113000000000000050PCE4  
DTM07 64 20160801                           102
DTM07 63 20160831                           102
QTY   113000000000000000PCE4  
DTM07 64 20160901                           102
DTM07 63 20160930                           102
QTY   113000000000000050PCE4  
DTM07 64 20161001                           102
DTM07 63 20161031                           102
QTY   113000000000000000PCE4  
DTM07 64 20161101                           102
DTM07 63 20161130                           102

I can do a lot of it with sed and its easier because you can edit files in place with sed, not used awk much so a little lost

Thank you again for taking the time to help.
 

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

Printing the line number in bash script

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)
Discussion started by: suryaemlinux
6 Replies

3. 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

4. Shell Programming and Scripting

Detecting key combination in bash

I need to grab key combination from a bash script and store it in a variable. Is there any way to do this? Thanks in advance! (1 Reply)
Discussion started by: prism1
1 Replies

5. UNIX for Dummies Questions & Answers

How to delete lines above a certin line number in bash shell

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)
Discussion started by: learninguser235
2 Replies

6. UNIX for Dummies Questions & Answers

How to delete lines above a certin line number in bash shell

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)
Discussion started by: learninguser235
5 Replies

7. 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

8. 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

9. 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

10. 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
ppmtosixel(1)						      General Commands Manual						     ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 11:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy