Sponsored Content
Homework and Emergencies Emergency UNIX and Linux Support getting wrong output with AWK command!!! Post 302355639 by dr.house on Wednesday 23rd of September 2009 09:41:53 AM
Old 09-23-2009
Ad hoc:

Code:
# more file.old
old text
old text
old text
# more file.new
old text
old text
old text
new text
new text
new text

Code:
# diff --suppress-common-lines file.old file.new | egrep '^[<|>]' | sed 's/[<|>] //'
new text
new text
new text

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

AWK command giving wrong input

Hi all, I have a problem with qwk command. i have to check process status and for that i am using command prstat -mvL 1 1 and it gives me the entire output but when i use this command with awk like this: prstat -mvL 1 1 | awk -F" " '{print $1,$15}' to get first and 15th arguments. ... (3 Replies)
Discussion started by: usha rao
3 Replies

2. Shell Programming and Scripting

Sort command giving wrong output

Hi all, I have a problem with sort command. i have a file which looks like this: "file1 1073 java/4 1073 java/180 1073 java/170 1073 java/176 1073 java/167 1073 java/40 1073 java/33 1073 java/136 28988 java/76 28988 java/73 28988 java/48 28988 java/26" and i want to sort... (8 Replies)
Discussion started by: usha rao
8 Replies

3. Shell Programming and Scripting

tr command giving wrong output

Hi All, i have a file which have many fields delimited by ,(comma) now i have to show only few fields and not all. the sample text file looks like this: TYPE=SERVICEEVENT, TIMESTAMP=05/06/2009 11:01:40 PM, HOST=sppwa634, APPLICATION=ASComp, FUNCTION=LimitsService, SOU... (8 Replies)
Discussion started by: usha rao
8 Replies

4. Shell Programming and Scripting

Wrong output in find command

Hi guys - I am trying a small script to tell me if there is a file that exists less than 1k. It should report ERROR, otherwise the check is good. I wrote this script down, however it never runs in the if/then statement. It always returns the echo ERROR. MYSIZE=$(find /home/student/dir1... (8 Replies)
Discussion started by: DallasT
8 Replies

5. Shell Programming and Scripting

Grep command showing wrong output in Linux

Hi All I am trying to run a script in linux wherein i have a command like this grep ^prmAttunityUser= djpHewr2XFMAttunitySetup_ae1_tmp djpHewr2XFMAttunitySetup_ae1_tmp is a temporary file in which the user value is stored but this command in the script returns me balnk value whereas it has a... (4 Replies)
Discussion started by: vee_789
4 Replies

6. Shell Programming and Scripting

Format output in AWK command

hi Friends , I have a file as below s.txt 1~2~~4 2~6~~7 3~8~~9 t.txt 1~2~~4 2~5~8~7 3~8~~7 header for both files is common (2 Replies)
Discussion started by: i150371485
2 Replies

7. Shell Programming and Scripting

If && command giving wrong output

Hi All, I am trying to run a script which will search for 2 strings(stopped,started) in a text file and echo an output depending on below condition -bash-3.2$ cat trial1.txt v ggg f -bash-3.2$ cat trial1.sh VAR9=` grep 'stopped' /tmp/trial1.txt` VAR10=` grep 'started'... (4 Replies)
Discussion started by: srkmish
4 Replies

8. Solaris

No output from awk command

Hi all, In my SunOS 5.10, the command awk using BEGIN option doesn't print output variables like expected here is my test: with the following code everything is alright ps -eo pcpu,args | grep "httpd" | awk ' { print $1 } ' the result is 0.1 However, with this command ps -eo... (3 Replies)
Discussion started by: Elmassimo
3 Replies

9. Shell Programming and Scripting

awk calculation wrong field output

The awk below is close but I can't seem to fix it to produce the desired output. Thank you :). current awk with output awk '{c1++; c2+=($2)} END{for (e in c1) print e, c1, c2}' input EFCAB5 2 50 USH2A 2 19 desired... (8 Replies)
Discussion started by: cmccabe
8 Replies

10. Shell Programming and Scripting

What is wrong with my awk command?

The below code usually works when the value for the COLUMN variable is numerical. but im in a situation where the number of fields in a file is not definitive. it changes. but what is static is that the value i want to retrieve from the log is 3 fields from the last field. which is what i... (9 Replies)
Discussion started by: SkySmart
9 Replies
SADF(1) 							Linux User's Manual							   SADF(1)

NAME
sadf - Display data collected by sar in multiple formats. SYNOPSIS
sadf [ -d | -j | -p | -x ] [ -C ] [ -H ] [ -h ] [ -T ] [ -t ] [ -V ] [ -P { cpu [,...] | ALL } ] [ -s [ hh:mm:ss ] ] [ -e [ hh:mm:ss ] ] [ -- sar_options ] [ interval [ count ] ] [ datafile ] DESCRIPTION
The sadf command is used for displaying the contents of data files created by the sar(1) command. But unlike sar, sadf can write its data in many different formats (CSV, XML, etc.) The default format is one that can easily be handled by pattern processing commands like awk (see option -p). The sadf command extracts and writes to standard output records saved in the datafile file. This file must have been created by a version of sar which is compatible with that of sadf. If datafile is omitted, sadf uses the standard system activity file, the /var/log/sys- stat/sadd file, where the dd parameter indicates the current day. The interval and count parameters are used to tell sadf to select count records at interval seconds apart. If the count parameter is not set, then all the records saved in the data file will be displayed. All the activity flags of sar may be entered on the command line to indicate which activities are to be reported. Before specifying them, put a pair of dashes (--) on the command line in order not to confuse the flags with those of sadf. Not specifying any flags selects only CPU activity. OPTIONS
-C Tell sadf to display comments present in file. -d Print the contents of the data file in a format that can easily be ingested by a relational database system. The output consists of fields separated by a semicolon. Each record contains the hostname of the host where the file was created, the interval value (or -1 if not applicable), the timestamp in a form easily acceptable by most databases, and additional semicolon separated data fields as specified by sar_options command line options. Note that timestamp output can be controlled by options -T and -t. -e [ hh:mm:ss ] Set the ending time of the report, given in local time. The default ending time is 18:00:00. Hours must be given in 24-hour format. -H Display only the header of the report (when applicable). If no format has been specified, then the header of the data file is dis- played. -h When used in conjunction with option -d, all activities will be displayed horizontally on a single line. -j Print the contents of the data file in JSON (JavaScript Object Notation) format. Timestamps can be controlled by option -t. -P { cpu [,...] | ALL } Tell sadf that processor dependent statistics are to be reported only for the specified processor or processors. Specifying the ALL keyword reports statistics for each individual processor, and globally for all processors. Note that processor 0 is the first pro- cessor. -p Print the contents of the data file in a format that can easily be handled by pattern processing commands like awk. The output con- sists of fields separated by a tab. Each record contains the hostname of the host where the file was created, the interval value (or -1 if not applicable), the timestamp, the device name (or - if not applicable), the field name and its value. Note that timestamp output can be controlled by options -T and -t. -s [ hh:mm:ss ] Set the starting time of the data (given in local time), causing the sadf command to extract records time-tagged at, or following, the time specified. The default starting time is 08:00:00. Hours must be given in 24-hour format. -T Display timestamp (UTC - Coordinated Universal Time) in seconds from the epoch. -t Display timestamp in local time instead of UTC (Coordinated Universal Time). -V Print version number then exit. -x Print the contents of the data file in XML format. Timestamps can be controlled by option -t. The corresponding DTD (Document Type Definition) and XML Schema are included in the sysstat source package. They are also available at http://pages- perso-orange.fr/sebastien.godard/download.html ENVIRONMENT
The sadf command takes into account the following environment variable: S_TIME_DEF_TIME If this variable exists and its value is UTC then sadf will use UTC time instead of local time to determine the current daily data file located in the /var/log/sysstat directory. EXAMPLES
sadf -d /var/log/sysstat/sa21 -- -r -n DEV Extract memory, swap space and network statistics from system activity file 'sa21', and display them in a format that can be ingested by a database. sadf -p -P 1 Extract CPU statistics for processor 1 (the second processor) from current daily data file, and display them in a format that can easily be handled by a pattern processing command. FILES
/var/log/sysstat/sadd Indicate the daily data file, where the dd parameter is a number representing the day of the month. AUTHOR
Sebastien Godard (sysstat <at> orange.fr) SEE ALSO
sar(1), sadc(8), sa1(8), sa2(8) http://pagesperso-orange.fr/sebastien.godard/ Linux NOVEMBER 2011 SADF(1)
All times are GMT -4. The time now is 11:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy