Sponsored Content
Top Forums Shell Programming and Scripting How to put a difference calculation in my awk script ? Post 303037617 by Tim2424 on Thursday 8th of August 2019 04:01:14 AM
Old 08-08-2019
Hello,

A late response, sorry... Smilie

Finally I do something different and make choice to create a other script for the difference calculation :


Code:
#!/bin/bash

cat /var/www/cgi-bin/test_calcul.csv | grep foo | awk -F'[,]' 'FNR==0{next}
               FNR>1{
                    print m " â†' " $1;
                    print "FRAME : " $2
                    printf "RAM : %+d%s",$4-RAM,ORS
                    printf "CPU 1 : %+d%s",$5-CPU1,ORS
                    printf "CPU 2 : %+d%s\n",$6-CPU2,ORS
                    }
               {m=$1;FRAME=$2}
               {m=$1;RAM=$4}
               {m=$1;CPU1=$5}
               {m=$1;CPU2=$6}
              '

And that works !

Thanks for your help ! Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Time difference calculation

Hi Team, I am currently in the process of writing a script which will take a filename in the format SKADEV.0.db2.NODE0000.CATN0000.20080714231015.001 where the sixth string(with "." as the seperator) is the time stamp of the time of creation of the file. now here is my issue . I need to be... (2 Replies)
Discussion started by: Segwar
2 Replies

2. Shell Programming and Scripting

Put the difference of two files in out file

Hello, I have two files file1 & file2 containing both lines (1 word per line). I need to extract the lines that are in file1 and not present in file2 and have the result in output file. i.e : user>cat file1 line1 line2 line3 line4 line5 user>cat file2 line1 line3 line5 The... (2 Replies)
Discussion started by: newpromo
2 Replies

3. Shell Programming and Scripting

calculation using awk or shell script in between the numbers

file A E969K D223L E400L E34L file B predicted 3 1 250 251 500 501 1000 The output should be E969K 501 1000 D223L 1 250 E400L 251 500 E34L 1 250 I tried in this way (1 Reply)
Discussion started by: cdfd123
1 Replies

4. Shell Programming and Scripting

AWK Script and Commandline difference

Hey there, I just stumbled upon a difference between using awk on the commandline and using it in a shellscript. I have a variable, e.g.: PROG=vim then i want to check if the package with this name is installed: TEMPVAL=$(dpkg -l | awk '{ if ($2 == "$PROG") print $2 }') (Im using... (10 Replies)
Discussion started by: MrSnail
10 Replies

5. Shell Programming and Scripting

Compare two CSV files and put the difference in third file with line no,field no and diff value.

I am having two csv files i need to compare these files and the output file should have the information of the differences at the field level. For Example, File 1: A,B,C,D,E,F 1,2,3,4,5,6 File 2: A,C,B,D,E,F 1,2,4,5,5,6 out put file: (12 Replies)
Discussion started by: karingulanagara
12 Replies

6. Shell Programming and Scripting

awk script - redirecting out put based on mapping

Need awk solution. Please advise. inputfile.txt 1,NY, 1111 2,MI, 222 3,NY,333 4,OH,444 5,OH,555 mapping.txt NY NYNY IL ILLINOIS OH OHIO Need to write a code which will compare 2nd column of inputfile.txt with mapping file and redirect output based on the... (2 Replies)
Discussion started by: vegasluxor
2 Replies

7. UNIX for Dummies Questions & Answers

Shell script - getting Time difference using awk

Hi..I have the data in a file like in this format, and I need the output time difference in seconds by using awk command. Start date/time and end date/time given in column 2,3 & 4,5. Please assist how to write shell script. File1.txt JOB1 10/09/2013 17:42:16 10/09/2013 17:43:46 SU 6202685/1... (4 Replies)
Discussion started by: mprithvi
4 Replies

8. Shell Programming and Scripting

awk script to find time difference between HTTP PUT and HTTP DELETE requests in access.log

Hi, I'm trying to write a script to determine the time gap between HTTP PUT and HTTP DELETE requests in the HTTP Servers access log. Normally client will do HTTP PUT to push content e.g. file_1.txt and 21 seconds later it will do HTTP DELETE, but sometimes the time varies causing some issues... (3 Replies)
Discussion started by: Juha
3 Replies

9. Shell Programming and Scripting

awk to calculate difference of split and sum the difference

In the awk I am trying to subtract the difference $3-$2 of each matching $4 before the first _ (underscore) and print that value in $13. I think the awk will do that, but added comments. What I am not sure off is how to add a line or lines that will add sum each matching $13 value and put it in... (2 Replies)
Discussion started by: cmccabe
2 Replies

10. Shell Programming and Scripting

How to put the command to remove duplicate lines in my awk script?

I create a CGI in bash/html. My awk script looks like : echo "<table>" for fn in /var/www/cgi-bin/LPAR_MAP/*; do echo "<td>" echo "<PRE>" awk -F',|;' -v test="$test" ' NR==1 { split(FILENAME ,a,""); } $0 ~ test { if(!header++){ ... (12 Replies)
Discussion started by: Tim2424
12 Replies
CSET-SHIELD(1)							  [FIXME: manual]						    CSET-SHIELD(1)

NAME
cset-shield - cpuset supercommand which implements cpu shielding SYNOPSIS
cset [cset options] shield [shield options] [args] cset shield --help cset shield cset shield --cpu 1-7 cset shield --cpu 1-7 --kthread=on cset shield --exec /opt/software/myapp/doit --my_opt1 --my_opt2 cset shield --user appuser --exec run_benchmark.sh cset shield --shield --pid 1024,2048,5000-1000 cset shield --unshield --pid 6000-8500 cset shield --kthread=off cset shield --kthread=on cset shield --shield bash OPTIONS
-h, --help prints the list of options for this command -c CPUSPEC, --cpu=CPUSPEC modifies or initializes the shield cpusets -r, --reset destroys the shield -e, --exec executes args in the shield --user=USER use this USER for --exec (id or name) --group=GROUP use this GROUP for --exec (id or name) -s, --shield shield PIDSPEC specified with -p/--pid of processes or threads -u, --unshield remove PIDSPEC specified with -p/--pid of processes or threads from the shield, the tasks keep running in the unshielded cpuset --threads if specified, any processes found in the PIDSPEC to have multiple threads will automatically have all their threads added to the PIDSPEC (use to shield or unshield all related threads) -k on|off, --kthread=on|off shield from unbound interrupt threads as well -f, --force force operation, use with care -v, --verbose prints more detailed output, additive --sysset=SYSSET optionally specify system cpuset name --userset=USERSET optionally specify user cpuset name DESCRIPTION
This is a supercommand that creates basic cpu shielding. The normal cset commands can of course be used to create this basic shield, but the shield command combines many such commands to create and manage a common type of cpu shielding setup. The concept of shielding implies at minimum three cpusets, for example: root, user and system. The root cpuset always exists in all implementations of cpusets and contains all available CPUs on the machine. The system cpuset is so named because normal system tasks are made to run on it. The user cpuset is so named because that is the "shielded" cpuset on which you would run your tasks of interest. Usually, CPU zero would be in the system set and the rest of the CPUs would be in the user set. After creation of the cpusets, all processes running in the root cpuset are moved to the system cpuset. Thus any new processes or threads spawned from these processes will also run the system cpuset. If the optional --kthread=on option is given to the shield command, then all kernel threads (with exception of the per-CPU bound interrupt kernel threads) are also moved to the system set. One executes processes on the shielded user cpuset with the --exec subcommand or moves processes or threads to the shielded cpuset with the --shield subcommand with a --pid option. Note You do not need to specify which cpuset a process or thread is running in initially when using the --shield subcommand. To create a shield, you would execute the shield command with the --cpu option that specifies CPUSPEC argument that assigns CPUs to be under the shield (this means assigned to the user cpuset, all other cpus will be assigned to the system set). For example: # cset shield --cpu=1-3 On a 4-way machine, this command will dedicate the first processor, CPU0, for the system set (unshielded) and the last three processors, CPU1, CPU2, CPU3, for the user set (shielded). The CPUSPEC will accept a comma separated list of CPUs and inclusive range specifications. For example, --cpu=1,3,5-7 will assign CPU1, CPU3, CPU5, CPU6, and CPU7 to the user (or shielded) cpuset and the inverse of that to the system (or unshielded) cpuset. If you do not like the names "system" and "user" for the unshielded and shielded sets respectively, or if those names are used already, then use the --sysset and --userset options. For example: # cset shield --sysset=free --userset=cage --cpu=2,3 --kthread=on The above command will use the name "free" for the unshielded system cpuset, the name "cage" for the shielded user cpuset, initialize these cpusets and dedicate CPU0 and CPU1 to the "free" set and (on a 4-way machine) dedicate CPU2 and CPU3 to the "cage" set. Further, the command moves all processes and threads, including kernel threads from the root cpuset to the "free" cpuset. Note If you do use the --syset/--userset options, then you must continue to use those for every invocation of the shield supercommand. After initialization, you can run the process of interest on the shielded cpuset with the --exec subcommand, or move processes or threads already running to the shielded cpuset with the --shield subcommand and the --pid option. Note that if your execed command takes options, then use the traditional "--" marker to separate cset's options from your command's options. For example: # cset shield --exec -- ls -l This command will execute "ls -l" inside the shield. The PIDSPEC argument taken for the --pid (or -p) option is a comma separated list of PIDs or TIDs. The list can also include brackets of PIDs or TIDs that are inclusive of the endpoints. For example: 1,2,5 Means processes 1, 2 and 5 1,2,600-700 Means processes 1, 2 and from 600 to 700 # cset shield --shield --pid=50-65 The above command moves all processes and threads with PID or TID in the range 50-65 inclusive, from the system cpuset into the shielded user cpuset. If they are running in the root cpuset, you must use the --force option to actually move them into the shield. Note The range of PIDs or TIDs does not need to have every position populated. In other words, for the example above, if there is only one process, say PID 57, in the range of 50-65, then only that process will be moved. The --unshield (or -u) subcommand will remove the specified processes or threads from the shielded cpuset and move them into the unshielded (or system) cpuset. This command is also used in conjuction with a -p/--pid option that specifies a PIDSPEC argument, the same as for the --shield subcommand. Both the --shield and the --unshield commands will also finally output the number of tasks running in the shield and out of the shield if you do not specify a PIDSPEC with --pid. By specifying also a --verbose in addition, then you will get a listing of every task that is running in either the shield or out of the shield. Using no subcommand, ie. only "cset shield", will output the status of both shield and non-shield. Tasks will be listed if --verbose is used. You can adjust which CPUs are in the shielded cpuset by issuing the --cpu subcommand again anytime after the shield has been initialized. For example if the original shield contained CPU0 and CPU1 in the system set and CPU2 and CPU3 in the user set, if you then issue the following command: # cset shield --cpu=1,2,3 then that command will move CPU1 into the shielded "user" cpuset. Any processes or threads that were running on CPU1 that belonged to the unshielded "system" cpuset are migrated to CPU0 by the system. The --reset subcommand will in essence destroy the shield. For example, if there was a shield on a 4-way machine with CPU0 in system and CPUs 1-3 in user with processes running on the user cpuset (i.e. in the shield), and a --reset subcommand was issued, then all processes running in both system and user cpusets would be migrated to the root cpuset (which has access to all CPUs and never goes away), after which both system and user cpusets would be destroyed. Note Even though you can mix general usage of cpusets with the shielding concepts described here, you generally will not want to. For more complex shielding or usage scenarios, one would generally use the normal cpuset commands (i.e. cset set and proc) directly. LICENSE
Cpuset is licensed under the GNU GPL V2 only. COPYRIGHT
Copyright (c) 2008-2011 Novell Inc. AUTHOR
Written by Alex Tsariounov <alext@novell.com>. SEE ALSO
cset(1), cset-set(1), cset-proc(1) /usr/share/doc/packages/cpuset/html/tutorial.html taskset(1), chrt(1) /usr/src/linux/Documentation/cpusets.txt [FIXME: source] 06/09/2011 CSET-SHIELD(1)
All times are GMT -4. The time now is 05:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy