Sponsored Content
Top Forums Shell Programming and Scripting Get output of fields starting from 2nd line Post 302770851 by DGPickett on Monday 18th of February 2013 03:50:23 PM
Old 02-18-2013
bash has a nice feature. You declare a simple array variable 'typedef -a myarray' and then 'while read -a myarray' and the fields are in the array for each line. Awk does that sort of thing natively.

BTW, free memory is a worthless spec in a VM system. That stat is left over from the old days of memory resident everything. delta page faults is more interesting, and load (cpu avg queue depth).
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to delete text from line starting pattern1 up to line before pattern2?

My data is xml'ish (here is an excerpt) :- <bag name="mybag1" version="1.0"/> <contents id="coins"/> <bag name="mybag2" version="1.1"/> <contents id="clothes"/> <contents id="shoes"/> <bag name="mybag3" version="1.6"/> I want to delete line containing mybag2 and its subsequent... (5 Replies)
Discussion started by: repudi8or
5 Replies

2. Shell Programming and Scripting

Compare multiple fields in file1 to file2 and print line and next line

Hello, I have two files that I need to compare and print out the line from file2 that has the first 6 fields matching the first 6 fields in file1. Complicating this are the following restrictions 1. file1 is only a few thousand lines at most and file2 is greater than 2 million 2. I need to... (7 Replies)
Discussion started by: gillesc_mac
7 Replies

3. UNIX for Dummies Questions & Answers

Write 2nd and 3rd fields to a 4th file name?

I have a flatfile A.txt date|products|notes|location 121117|a108|this is a test|florida 121118|b111|just test it|tampa How do i write an awk to create a file name as location.txt and have products:notes awk -F'|' '{ print $2 ":" $3 }' A.txt > $4.txt I am sure it cannot write to... (5 Replies)
Discussion started by: sabercats
5 Replies

4. Shell Programming and Scripting

Comparison of fields then increment a counter reading line by line in a file

Hi, i have a scenario were i should compare a few fields from each line then increment a variable based on that. Example file 989878|8999|Y|0|Y|N|V 989878|8999|Y|0|N|N|V 989878|8999|Y|2344|Y|N|V i have 3 conditions to check and increment a variable on every line condition 1 if ( $3... (4 Replies)
Discussion started by: selvankj
4 Replies

5. Shell Programming and Scripting

How to print line starting with certain string together with its following line?

Dear all, How can I print line starting with certain string together with its following line. Example is as follows: Input file: @M01596:22:000000000-A7YH7:1:1101:16615:1070 2:N:0:1... (2 Replies)
Discussion started by: huiyee1
2 Replies

6. Shell Programming and Scripting

How to read file line by line and compare subset of 1st line with 2nd?

Hi all, I have a log file say Test.log that gets updated continuously and it has data in pipe separated format. A sample log file would look like: <date1>|<data1>|<url1>|<result1> <date2>|<data2>|<url2>|<result2> <date3>|<data3>|<url3>|<result3> <date4>|<data4>|<url4>|<result4> What I... (3 Replies)
Discussion started by: pat_pramod
3 Replies

7. Shell Programming and Scripting

With script bash, read file line per line starting at the end

Hello, I'm works on Ubuntu server My goal : I would like to read file line per line, but i want to started at the end of file. Currently, I use instructions : while read line; do COMMAND done < /var/log/apache2/access.log But, the first line, i don't want this. The file is long... (5 Replies)
Discussion started by: Fuziion
5 Replies

8. UNIX for Dummies Questions & Answers

How to grep a line not starting with # from a file (there are two lines starting with # and normal)?

e.g. File name: File.txt cat File.txt Result: #INBOUND_QUEUE=FAQ1 INBOUND_QUEUE=FAQ2 I want to get the value for one which is not commented out. Thanks, (3 Replies)
Discussion started by: Tanu
3 Replies

9. Shell Programming and Scripting

Remove new line starting with a numeric value and append it to the previous line

Hi, i have a file with multiple entries. After some tests with sed i managed to get the file output as follows: lsn=X-LINK-IN0,apc=661:0,state=avail,avail/links=1/1, 00,2110597,2094790,0,81,529,75649011,56435363, lsn=TM1ITP1-AM1ITP1-LS,apc=500:0,state=avail,avail/links=1/1,... (5 Replies)
Discussion started by: nms
5 Replies

10. UNIX for Beginners Questions & Answers

Get an output of lines in pattern 1st line then 10th line then 11th line then 20th line and so on.

Input file: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 (6 Replies)
Discussion started by: Sagar Singh
6 Replies
Sys::Statistics::Linux::Processes(3pm)			User Contributed Perl Documentation		    Sys::Statistics::Linux::Processes(3pm)

NAME
Sys::Statistics::Linux::Processes - Collect linux process statistics. SYNOPSIS
use Sys::Statistics::Linux::Processes; my $lxs = Sys::Statistics::Linux::Processes->new; # or Sys::Statistics::Linux::Processes->new(pids => @pids) $lxs->init; sleep 1; my $stat = $lxs->get; DESCRIPTION
Sys::Statistics::Linux::Processes gathers process information from the virtual /proc filesystem (procfs). For more information read the documentation of the front-end module Sys::Statistics::Linux. PROCESS STATISTICS
Generated by /proc/<pid>/stat, /proc/<pid>/status, /proc/<pid>/cmdline and getpwuid(). Note that if /etc/passwd isn't readable, the key owner is set to N/a. ppid - The parent process ID of the process. nlwp - The number of light weight processes that runs by this process. owner - The owner name of the process. pgrp - The group ID of the process. state - The status of the process. session - The session ID of the process. ttynr - The tty the process use. minflt - The number of minor faults the process made. cminflt - The number of minor faults the child process made. mayflt - The number of mayor faults the process made. cmayflt - The number of mayor faults the child process made. stime - The number of jiffies the process have beed scheduled in kernel mode. utime - The number of jiffies the process have beed scheduled in user mode. ttime - The number of jiffies the process have beed scheduled (user + kernel). cstime - The number of jiffies the process waited for childrens have been scheduled in kernel mode. cutime - The number of jiffies the process waited for childrens have been scheduled in user mode. prior - The priority of the process (+15). nice - The nice level of the process. sttime - The time in jiffies the process started after system boot. actime - The time in D:H:M:S (days, hours, minutes, seconds) the process is active. vsize - The size of virtual memory of the process. nswap - The size of swap space of the process. cnswap - The size of swap space of the childrens of the process. cpu - The CPU number the process was last executed on. wchan - The "channel" in which the process is waiting. fd - This is a subhash containing each file which the process has open, named by its file descriptor. 0 is standard input, 1 standard output, 2 standard error, etc. Because only the owner or root can read /proc/<pid>/fd this hash could be empty. cmd - Command of the process. cmdline - Command line of the process. Generated by /proc/<pid>/statm. All statistics provides information about memory in pages: size - The total program size of the process. resident - Number of resident set size, this includes the text, data and stack space. share - Total size of shared pages of the process. trs - Total text size of the process. drs - Total data/stack size of the process. lrs - Total library size of the process. dtp - Total size of dirty pages of the process (unused since kernel 2.6). It's possible to convert pages to bytes or kilobytes. Example - if the pagesize of your system is 4kb: $Sys::Statistics::Linux::Processes::PAGES_TO_BYTES = 0; # pages (default) $Sys::Statistics::Linux::Processes::PAGES_TO_BYTES = 4; # convert to kilobytes $Sys::Statistics::Linux::Processes::PAGES_TO_BYTES = 4096; # convert to bytes # or with Sys::Statistics::Linux::Processes->new(pages_to_bytes => 4096); Generated by /proc/<pid>/io. rchar - Bytes read from storage (might have been from pagecache). wchar - Bytes written. syscr - Number of read syscalls. syscw - Numner of write syscalls. read_bytes - Bytes really fetched from storage layer. write_bytes - Bytes sent to the storage layer. cancelled_write_bytes - Refer to docs. See Documentation/filesystems/proc.txt for more (from kernel 2.6.20) METHODS
new() Call "new()" to create a new object. my $lxs = Sys::Statistics::Linux::Processes->new; It's possible to handoff an array reference with a PID list. my $lxs = Sys::Statistics::Linux::Processes->new(pids => [ 1, 2, 3 ]); It's also possible to set the path to the proc filesystem. Sys::Statistics::Linux::Processes->new( files => { # This is the default path => '/proc', uptime => 'uptime', stat => 'stat', statm => 'statm', status => 'status', cmdline => 'cmdline', wchan => 'wchan', fd => 'fd', io => 'io', } ); init() Call "init()" to initialize the statistics. $lxs->init; get() Call "get()" to get the statistics. "get()" returns the statistics as a hash reference. my $stat = $lxs->get; Note: Processes that were created between the call of init() and get() are returned as well, but the keys minflt, cminflt, mayflt, cmayflt, utime, stime, cutime, and cstime are set to the value 0.00 because there are no inititial values to calculate the deltas. raw() Get raw values. EXPORTS
No exports. SEE ALSO
proc(5) perldoc -f getpwuid REPORTING BUGS
Please report all bugs to <jschulz.cpan(at)bloonix.de>. AUTHOR
Jonny Schulz <jschulz.cpan(at)bloonix.de>. COPYRIGHT
Copyright (c) 2006, 2007 by Jonny Schulz. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-03-09 Sys::Statistics::Linux::Processes(3pm)
All times are GMT -4. The time now is 08:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy