Sponsored Content
Top Forums Shell Programming and Scripting AWK SCRIPT HELP : INCREMENTING PROBLEM Post 302504030 by jaita on Sunday 13th of March 2011 07:29:20 AM
Old 03-13-2011
Network AWK SCRIPT HELP : INCREMENTING PROBLEM

Hi Guys ,

I am having one command file like this

FILE1

################################

Code:
 
awk '/output/ {a[FNR]=$2}   {for(i=1;i<=NF;i++)  { gsub("i1", i) ; gsub("i2",++i) ; gsub("P1", p) }}1' output >> out9

awk '/output/ {a[FNR]=$2}   {for(i=1;i<=NF;i++)  { gsub("i1", i) ; gsub("i2",++i) ; gsub("P1", p) }}1' output >> out9

awk '/output/ {a[FNR]=$2}   {for(i=1;i<=NF;i++)  { gsub("i1", i) ; gsub("i2",++i) ; gsub("P1", p) }}1' output >> out9

awk '/output/ {a[FNR]=$2}   {for(i=1;i<=NF;i++)  { gsub("i1", i) ; gsub("i2",++i) ; gsub("P1", p) }}1' output >> out9

awk '/output/ {a[FNR]=$2}   {for(i=1;i<=NF;i++)  { gsub("i1", i) ; gsub("i2",++i) ; gsub("P1", p) }}1' output >> out9

################################################

I want to Increment the variable "p" like to have the Expected output as shown below

OUTPUT FILE

#############################################
Code:
 
awk '/output/ {a[FNR]=$2}   {for(i=1;i<=NF;i++)  { gsub("i1", i) ; gsub("i2",++i) ; gsub("P1", 1) }}1' output >> out9

 
awk '/output/ {a[FNR]=$2}   {for(i=1;i<=NF;i++)  { gsub("i1", i) ; gsub("i2",++i) ; gsub("P1", 2) }}1' output >> out9

 
awk '/output/ {a[FNR]=$2}   {for(i=1;i<=NF;i++)  { gsub("i1", i) ; gsub("i2",++i) ; gsub("P1", 3) }}1' output >> out9

 
awk '/output/ {a[FNR]=$2}   {for(i=1;i<=NF;i++)  { gsub("i1", i) ; gsub("i2",++i) ; gsub("P1", 4) }}1' output >> out9

 
awk '/output/ {a[FNR]=$2}   {for(i=1;i<=NF;i++)  { gsub("i1", i) ; gsub("i2",++i) ; gsub("P1", 5) }}1' output >> out9

############################################

Increment p to 1 , 2 ,3 4 and 5 kind of

I am using this awk script as shown below

awk {for(i=0;i<=5;i++) {gsub("p",i) }}' FILE1

But I am getting same value like 0 in the Output file

How will it be incremented

Thanks
Jaita
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk script Problem

I wrote a awk but doesnt work as expected. The Input File attached input file My awk Script /^.......*EXEC CICS /,/END-EXEC/ { if ( $0 ~ / LINK / ) { tsflag=1 } if ( $0 ~ /EXEC CICS/ && tsflag == 1 ) ... (6 Replies)
Discussion started by: pbsrinivas
6 Replies

2. Shell Programming and Scripting

shell script help: sorting, incrementing environment variables and stuff

First: me == noob. Whats a good resource for shell script info cause I'm having trouble finding good info. I'm writing a shell script to automate the setup of a flash 'page flip'. My current code is below. the page flip takes an xml file of format <content> <pages... (1 Reply)
Discussion started by: secoif
1 Replies

3. UNIX for Dummies Questions & Answers

can anybody help me out in writing the script for incrementing the specific field

can anybody help me out in writing the any script (awk,shell or perl script) for incrementing the specific field highlighted below /{/data/{/assetMetricsList//{1]/dailyCount,........./{/data/{/assetMetricsList//{100]/dailyCount It should be in below format in oneline seperated by commas ... (1 Reply)
Discussion started by: swapnak
1 Replies

4. Programming

Interesting Problem About Incrementing ++

Here is my code: int startingPort = 200; string tempPort; stringstream out; out<<startingPort; tempPort = out.str(); //tempPort carries startingPort in string format //convert tempPort to *char - currentPort going to be passed into getaddrinfo() char currentPort;... (10 Replies)
Discussion started by: f.ben.isaac
10 Replies

5. Shell Programming and Scripting

Problem with AWK script

Help Please I have 2 files. each file contain 2 columns.1st file 1st column contain symbols (keys-a1..a22..a-x,a-y) and 1st file 2nd column contain values (any like 2344,434323). Secondfile also the same but the values are may be different or not and the symbols (keys) are same but may be... (0 Replies)
Discussion started by: repinementer
0 Replies

6. Shell Programming and Scripting

Problem with a AWK Script

Hi I am having some contents in my file like this file1 ########################## pin (PIN1) { direction : input ; capacitance : 121 ; max_transition : 231 ; } pin (PIN2) { direction : input ; capacitance : 124 ; max_transition : 421 ;... (8 Replies)
Discussion started by: kshitij
8 Replies

7. Shell Programming and Scripting

Facing problem in incrementing the variable

When I did, echo $SHELL in cmd prompt of putty, its displaying /bin/sh And in my shell script., I hav started with., #!/bin/sh and i=1; while ; do . . . i=$; (9 Replies)
Discussion started by: av_vinay
9 Replies

8. Shell Programming and Scripting

awk script problem

Hi I am having a big file where the interested section is shown below I need to write one awk script to search for the _N thing and delete it till the blank space means _N1 or _N4 everything needs to be deleted Removing the links like _N402 and like that ... (5 Replies)
Discussion started by: jaita
5 Replies

9. Shell Programming and Scripting

Awk script Problem

Hi , I am having two files FILE1 and FILE2 as shown below I need to search each and every element of Coulumn1 in the FILE1 in FILE2 and Globally replace with the Corresponding element of the Column2 in the FILE2 , For example and1 which is the first element of COl 1 of the FILE1 should be... (4 Replies)
Discussion started by: jaita
4 Replies

10. Shell Programming and Scripting

Incrementing the date depending on the Counter (parameter) passed to the script

Hello Everyone, I have been trying to complete a shell script where, I need to increment the date depending on the file (depending on the date) availability on the remote server. i.e. Basically, I will be passing a counter (like parameter 1 or 2 or 3 or 4). First I will check for the... (1 Reply)
Discussion started by: filter
1 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 07:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy