Sponsored Content
Top Forums Shell Programming and Scripting Fix script to get missing information Post 302927059 by jiam912 on Sunday 30th of November 2014 03:12:11 PM
Old 11-30-2014
Fix script to get missing information

Gents,

Can you please help me to fix the following script in order to get complete data as desired. I am missing some data in output.

the complete input file is attached.

The script I am using is

Code:
awk '{\
       status=substr($0,91,2)\
       ind=substr($0,26,1);\
       split(substr($0, 11, 24-11), val,/\.0 /);\
       key[NR%2":"val[1]val[2]] = ind":"status\
     }\
     END{\
       for(i in key){\
         split(i, arr, /:/)\
         split(key[i], brr, /:/)\
         if(!(brr[2] == '$st1' || brr[2] == '$st2')){\
           delete key[i]\
           continue\
         }\
         cnt[arr[2]]++\
      }\
      for(i in key){\
        split(i, arr, /:/)\
        split(key[i], brr, /:/)\
        print arr[2]" index "brr[1]" has "cnt[arr[2]]" times status "brr[2]\
      }\
    }' input.txt | sort -k1,1n -u > output

Output I get

Code:
6936919969 index 2 has 2 times status 14
6937919401 index 3 has 2 times status 14
6938720105 index 2 has 2 times status 14
6957719489 index 4 has 2 times status 98
6957919489 index 2 has 2 times status 98
6958119529 index 2 has 2 times status 14
6958320209 index 2 has 2 times status 14
6958719737 index 2 has 2 times status 14
6958920185 index 2 has 2 times status 14
6959120009 index 1 has 1 times status 98
6959320089 index 1 has 1 times status 98

Output I will like to get

Code:
6936919969 index 2 has 2 times status 14
6937919401 index 2 has 2 times status 14
6937919401 index 3 has 2 times status 14
6938720105 index 2 has 2 times status 14
6957719489 index 1 has 2 times status 98
6957719489 index 2 has 2 times status 98
6957719489 index 3 has 2 times status 98
6957719489 index 4 has 2 times status 98
6957919489 index 1 has 2 times status 98
6957919489 index 2 has 2 times status 98
6958119529 index 2 has 2 times status 14
6958320209 index 2 has 2 times status 14
6958719737 index 2 has 2 times status 14
6958920185 index 2 has 2 times status 14
6959120009 index 1 has 1 times status 98
6959320089 index 1 has 1 times status 98

Thanks for your help
 

9 More Discussions You Might Find Interesting

1. Linux

missing in script

Hi , I am trying to make this change work in my script but its not working.The idea is to grep for "CREATE VIEW" and then change view name from orig to VW_orig. but the problem comes when there is no schema prefix to the view name . the code I am using is #!/bin/ksh... (5 Replies)
Discussion started by: capri_drm
5 Replies

2. Shell Programming and Scripting

fix a problem in this script

z=9 i=0 h=02 min=55 while do cat /home/barmecha/test | grep $h:$min >> /home/barmecha/file1 min=`expr $min + 1` if ; then h=`expr $h + 1` fi i=`expr $i + 1` done i have a log file with time wise log in it, this script help me to pull out logs of the give time interval...but the... (8 Replies)
Discussion started by: abhishek27
8 Replies

3. Shell Programming and Scripting

how to fix this awk script?

i have a log file while looks like this ++ user_a blabla blabla nas_b blabla user_d this is a user_a junk line another junk line user_c nas_m blabla ++ basically most of the lines contain a "user" keywords, and the rest of the lines do not have "user" at all. So I have the... (17 Replies)
Discussion started by: fedora
17 Replies

4. Shell Programming and Scripting

Fix CSV file with column missing quotes

I have a CSV file that is missing quotes around a column that contains text with commas. Example: Column1, Column2, Column3, Column4, Column5, Column6 Data1, Data2, Data3, Data, 4, Data5, Data6 Data1, Data3, Data3, Data, text, 4, Data5, Data6 I think the easiest way for me to fix this is to... (2 Replies)
Discussion started by: EmptyH
2 Replies

5. Windows & DOS: Issues & Discussions

Fix script error (%%n)

Hi, I'm currently tinkering with a script that uses the for command to process all *.gif files in the current folder. I marked the spot where it exits out with an error by adding a "pause" The error message given is: convert.exe: unable to open image `%x': No such file or directory @... (2 Replies)
Discussion started by: pasc
2 Replies

6. UNIX for Dummies Questions & Answers

Please help to fix awk script

Good morning, fellows. I would need to ask for your help in editing my awk script. Here is the original version: BEGIN { printf ("CRYST1 200.000 200.000 200.000 90.00 90.00 90.00 P 1 1\n") maxatoms=1000 natom=0 found_struct = 0 found_bond = 0 } { if( NF == 5 ) { foundff=0 natom++... (9 Replies)
Discussion started by: snysmumrik
9 Replies

7. Shell Programming and Scripting

How to fix my IMDB Script

Hello, I am using IMDB bot file for my movie site.. But I get this message like this---Parse error: syntax error, unexpected end of file, expecting variable (T_VARIABLE) or ${ (T_DOLLAR_OPEN_CURLY_BRACES) or {$ (T_CURLY_OPEN) in... (2 Replies)
Discussion started by: lg2013
2 Replies

8. Shell Programming and Scripting

My script failed and can't fix it ?

Hi , I'd like to give you a little bit idea about my script which is used to get any generated file from remote server using ftp session then organized those file into directories based on their date ( at the end I supposed to have 1 months directories 20130401 20130402 ....20130430 ,... (27 Replies)
Discussion started by: arm
27 Replies

9. Shell Programming and Scripting

Missing information in output file

Gents, Using the following code i am able to output the information i need, but some of the strings are not complete due to the separator : used.. Kindly can u help me to get all string after the first : Example in the output file column 16 i should get 17/11/25 03:43:51:732000 but i... (8 Replies)
Discussion started by: jiam912
8 Replies
NPM-RUN-SCRIPT(1)														 NPM-RUN-SCRIPT(1)

NAME
npm-run-script - Run arbitrary package scripts SYNOPSIS
npm run-script <command> [--silent] [-- <args>...] alias: npm run DESCRIPTION
This runs an arbitrary command from a package's "scripts" object. If no "command" is provided, it will list the available scripts. run[-script] is used by the test, start, restart, and stop commands, but can be called directly, as well. When the scripts in the package are printed out, they're separated into lifecycle (test, start, restart) and directly-run scripts. As of ` https://blog.npmjs.org/post/98131109725/npm-2-0-0, you can use custom arguments when executing scripts. The special option -- is used by getopt https://goo.gl/KxMmtG to delimit the end of the options. npm will pass all the arguments after the -- directly to your script: npm run test -- --grep="pattern" The arguments will only be passed to the script specified after npm run and not to any pre or post script. The env script is a special built-in command that can be used to list environment variables that will be available to the script at run- time. If an "env" command is defined in your package, it will take precedence over the built-in. In addition to the shell's pre-existing PATH, npm run adds node_modules/.bin to the PATH provided to scripts. Any binaries provided by locally-installed dependencies can be used without the node_modules/.bin prefix. For example, if there is a devDependency on tap in your package, you should write: "scripts": {"test": "tap test/*.js"} instead of "scripts": {"test": "node_modules/.bin/tap test/*.js"} to run your tests. The actual shell your script is run within is platform dependent. By default, on Unix-like systems it is the /bin/sh command, on Windows it is the cmd.exe. The actual shell referred to by /bin/sh also depends on the system. As of ` https://github.com/npm/npm/releases/tag/v5.1.0 you can customize the shell with the script-shell configuration. Scripts are run from the root of the module, regardless of what your current working directory is when you call npm run. If you want your script to use different behavior based on what subdirectory you're in, you can use the INIT_CWD environment variable, which holds the full path you were in when you ran npm run. npm run sets the NODE environment variable to the node executable with which npm is executed. Also, if the --scripts-prepend-node-path is passed, the directory within which node resides is added to the PATH. If --scripts-prepend-node-path=auto is passed (which has been the default in npm v3), this is only performed when that node executable is not found in the PATH. If you try to run a script without having a node_modules directory and it fails, you will be given a warning to run npm install, just in case you've forgotten. You can use the --silent flag to prevent showing npm ERR! output on error. You can use the --if-present flag to avoid exiting with a non-zero exit code when the script is undefined. This lets you run potentially undefined scripts without breaking the execution chain. SEE ALSO
o npm help 7 scripts o npm help test o npm help start o npm help restart o npm help stop o npm help 7 config January 2019 NPM-RUN-SCRIPT(1)
All times are GMT -4. The time now is 02:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy