Visit Our UNIX and Linux User Community


Bash script to count and insert


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash script to count and insert
# 8  
Old 08-27-2013
@Jotne - yes, default action is print and we don't need that. However I added it for better readability for a beginner.
# 9  
Old 08-27-2013
Nearly there I think, slight problem, instead of count up its going 1 - 21, 3 - 41, 5 - 61

Also the second set of numbers 21,41,61 are at position 87 instead of 88, see below, thanks again for the help guys

Code:
71402144002-300            Y726B/0               0060000000800000ST0000028000000ST    001                S        G             
71502304413-000            B4                    000000000000100100000000000001       21                                    M   
715023044EC-000            B3                    000000000000800100000001000003       41                                    S   
715023044H0-000            B5                    000000000000100100000000000005       61                                        
7130200619802130823CV10003    5500048091        024                  024                                                        
71402144003-300            Y727B/0               0060000001200000ST0000028300000ST    001                S        G             
71502304413-000            B4                    000000000000100100000000000007       81                                    M   
715023044EC-000            B3                    000000000001200100000001000009       10                                    S   
715023044H0-000            B5                    0000000000001001000000000000011      12                                        
7130200619803130823CV10003    5500048085        024                  024                                                        
71402144005-300            Y729B/0               0060000000700000ST0000028700000ST    001                S        G             
71502304413-000            B4                    0000000000001001000000000000013      14                                    M   
715023044EC-000            B3                    0000000000004001000000017500015      16                                    S   
715023044H0-000            B5                    0000000000001001000000000000017      18                                        
7130200619804130823CV10003    5500107982        024                  024                                                        
71402938266-100            Y762/0                0060000000640000ST0000038080000ST    001                S        G             
71502304413-000            B4                    0000000000001001000000000000019      20                                    M   
715023044EC-000            B3                    0000000000008001000000008000021      22                                    S   
715023044H0-000            B5                    0000000000001001000000000000023      24


Previous Thread | Next Thread
Test Your Knowledge in Computers #436
Difficulty: Easy
React is an open source JavaScript library.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Python Script to take file count and insert into DB2 table

Team I have files in different directories . How can i take the count of latest file and insert into Db2 table . I am using awk 'END{print NR+1-ARGC}' (File name) to get the counts. How can i take 1.The count of latest file 2.Insert into Db2 table( File Name and Counts) . cd... (4 Replies)
Discussion started by: Perlbaby
4 Replies

2. UNIX for Beginners Questions & Answers

BASH SCRIPT - Insert date into cells in cvs file

Hi, I'm looking to accomplish the following. Insert current date into three places/cells within a cvs, every time the bash script is executed. The cells are column A,B,C row 2. Row 1 is reserved for the headers. The file name is always orders.csv. These three cells we always have an old... (1 Reply)
Discussion started by: Rookievmc
1 Replies

3. Shell Programming and Scripting

Linux shell script to insert new lines based on delimiter count

The input file is a .dat file which is delimited by null (^@ in Linux). On a windows PC it looks something like this (numbers are masked with 1). https://i.imgur.com/nta2Gqp.jpg The entire file is in one row but it has multiple records - each record contains 80 fields i.e. there are 81 counts... (9 Replies)
Discussion started by: digitalnirvana
9 Replies

4. Shell Programming and Scripting

Insert Columns before the last Column based on the Count of Delimiters

Hi, I have a requirement where in I need to insert delimiters before the last column of the total delimiters is less than a specified number. Say if the delimiters is less than 139, I need to insert 2 columns ( with blanks) before the last field awk -F '' '{ if (NF-1 < 139)} END { "Insert 2... (5 Replies)
Discussion started by: arunkesi
5 Replies

5. Shell Programming and Scripting

Help with insert a value equation in bash script

HI All, I have a script in bash that i want that script will perform action When the size of a particular folder exceeds the 80%. Here is an example of script that result is exactly 80% : #!/bin/bash CHECK=$(df -h /var/log/syslog | grep '80%' | xargs echo | cut -d' ' -f5) if ];... (1 Reply)
Discussion started by: Aviel.shani
1 Replies

6. Shell Programming and Scripting

bash script search file and insert character when match found

Hi I need a bash script that can search through a text file and when it finds 'FSS1206' I need to put a Letter F 100 spaces after the second instance of FSS1206 The format is the same throughout the file I need to repeat this on every time it finds the second 'FSS1206' in the file I have... (0 Replies)
Discussion started by: firefox2k2
0 Replies

7. UNIX for Dummies Questions & Answers

Bash script to insert data into an html table

hi, I need to create a bash shell script which picks up data from a text file and in the output file puts it into an html made table. I have to use sed and awk utilties to do this the input text file will contain data in the format: job name para1 para2 para3 para4 para4 1 ... (1 Reply)
Discussion started by: intern123
1 Replies

8. Shell Programming and Scripting

count and compare no of records in bash shell script.

consider this as a csv file. H,0002,0002,20100218,17.25,P,barani D,1,2,3,4,5,6,7,8,9,10,11 D,1,2,3,4,5,6,7,8,9,10,11 D,1,2,3,4,5,6,7,8,9,10,11 D,1,2,3,4,5,6,7,8,9,10,11 D,1,2,3,4,5,6,7,8,9,10,11 T,5 N i want to read the csv file and count the number of rows that start with D and... (11 Replies)
Discussion started by: barani75
11 Replies

9. Shell Programming and Scripting

insert leading zeroes based on the character count

Hi, I need add leading zeroes to a field in a file based on the character count. The field can be of 1 character to 6 character length. I need to make the field 14bytes. eg: 8351,20,1 8351,234,6 8351,2,0 8351,1234,2 8351,123456,1 8351,12345,2 This should become. ... (3 Replies)
Discussion started by: gpaulose
3 Replies

10. Shell Programming and Scripting

bash script to count the time of transaction

Halo, Bash Script can get the time of process the trasaction or not? For example, bash script use to procee the trasaction, like select and checking.. then generate the XML. after it, i need to get the time which to count the process. Anyone can help me? Thank you (1 Reply)
Discussion started by: ryanW
1 Replies

Featured Tech Videos