How to change a PS attribute?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to change a PS attribute?
# 1  
Old 11-25-2017
How to change a PS attribute?

Hi,

i want to list all system processes showing the attributes pid, user name, cpu consumption, and the difference between the resident memory and the swap memory needed to stock the process in case of suspending it.

i have two questions, the resident memory is the attribute size i think, but what attribute is the swap memory? vsize maybe?

And the 2nd question, if want to do the difference between those two values, is there a way to output this value on the same line as this command?
Code:
ps axo ppid,pcpu,priority,size,vsize,user

i want to convert size and vsize onto one attribute and show there the difference between those two. can i do that on that same line?

Thank you very much for your help, and once again sorry for my english i dont know if i explained myself correctly.
# 2  
Old 11-25-2017
You could pipe your ps command through awk.

e.g.
Code:
ps ... | awk '{print $1 FS $2 FS $3 FS $5-$4 FS $6}'

Code:
ps ... | awk '{$4 = $5-$4; $5=""}1'

Code:
ps ... | awk '{$4 = $5-$4; $5=$6; NF=5}1'

Or something like that.

Or add an extra column with the new info:
Code:
ps ... | awk '{$5 = $5 FS $5-$4 FS}1'

# 3  
Old 11-25-2017
Code:
PPID %CPU PRI SIZE VSZ 0  USER
0 0.0 20 0 10436 10436  root
1 0.0 20 0 28392 28392  Eskizoide
1 0.0 20 0 28392 28392  Eskizoide
2 0.0 20 0 43776 43776  Eskizoide
424 0.0 20 0 58672 58672  Eskizoide
49 0.0 20 0 46624 46624  Eskizoide
49 0.0 20 0 46180 46180  Eskizoide

Thats the output for what you said. I've used awk before but i dont know what thats suppose to do, i know you are doing the difference between $5 and $4 that are the attributes that we want to operate with, but what FS does? or that 1 at the end of the line?

Thanks for the reply.
# 4  
Old 11-25-2017
FS is the (awk) field separator. In most cases, you could just replace that with a space (" "). Using FS is mostly only useful if you provide awk with a field separator to begin with (which is not the case here). The 1 at the end is a condition, which is always true, which performs an action. The default action is print. As no action is given, the 1 will just "print" the line.

This could be re-written as, for example:
Code:
ps ... | awk '{$5 = $5 FS $5-$4 FS; print}'

Or
Code:
ps ... | awk '{$5 = $5 FS $5-$4 FS}{print}'

# 5  
Old 11-25-2017
So useful, thank you very much Scott, i think im staying here Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Change attribute value in xml using shell script

hi, i am new to unix and i have a problem. -------------------------------------------------------------- sebben.xml <envelope> <email> sebben@example.com </email> </envelope> script_mail written in the vi editor. #!/bin/sh script to change the value in attribute <email> echo... (3 Replies)
Discussion started by: sebbenw
3 Replies

2. UNIX for Dummies Questions & Answers

How to use xml_grep to get the value of an attribute?

I'm using xml_grep command to get the value of different tags in a xml-file. No i also need the value of an attribute in a tag. Can I use xml_grep for this? Does anybody know how? ex. : <Name xmlns:xsi="http://www.w3.org/2001/XMLinst" xsi:spaceSchema="Name_5879.xsd"> ... </Name> I... (1 Reply)
Discussion started by: pistach
1 Replies

3. AIX

hacmp user attribute change

Hi Mine is a two node ha cluster. i have a user named sybase for whom i was asked to change the stack and memory value to unlimited in one of the node. i know that it can be done via smitty chuser. but will it impact as i will be doing the changes in only one of the node. the user sybase is... (2 Replies)
Discussion started by: newtoaixos
2 Replies

4. Solaris

Solaris Attribute Problems

When I modify the file attributes of files and run a ls -l to view the changes everything looks correct, however when I run the init 6 to reboot the server the file attributes devert back to the origininal read only permissions. Any help would be appreciated (2 Replies)
Discussion started by: jimcz2it
2 Replies

5. Linux

Unable to get terminal attribute!

Hi, I'm using scli (Command line utility) to retrieve the information about qlogic HBA and I want to redirect the information to text file. * While execution I'm getting the following warning "Unable to get terminal attribute!" How to avoid that ? because of this "Unable to get terminal... (3 Replies)
Discussion started by: shausy
3 Replies

6. AIX

login attribute settign

Dears i need some assistance in implementing following scenario, as per audit observation we have restrict remote log in of specific users after official hours by clients, but the same user needs to be log in from LFT console round the clock(or any time after logout,because certain application... (1 Reply)
Discussion started by: m_raheelahmed
1 Replies

7. Red Hat

Password Attribute

Hello Friends , Where do i check the following settings in redhat ? 1. Minimum required number of characters in the password (passwordMinLength) 2. Minimum number of digit characters, meaning numbers between zero and nine (passwordMinDigits) 3. Minimum number of ASCII alphabetic... (2 Replies)
Discussion started by: avklinux
2 Replies

8. Shell Programming and Scripting

Dynamic Attribute Changes

Hello , I am stuck out in a part of my script, though I am trying it through a script of loops but i emphasis on having a short code : Input file has Attribute values changing with time Date Monday October 30 10:22:56 IST 2006 object values references Date ... (8 Replies)
Discussion started by: er_aparna
8 Replies

9. Programming

UNIX->C++ File attribute

Hi to all, I need in Microsoft C++ to IDENTIFY unix files which are LINKS. I use CFTPFILEFIND class. Thanks :-) .:rolleyes: (0 Replies)
Discussion started by: mizrachi
0 Replies

10. Linux

File attribute Help please

Could anyone help i have a question that i have a problem with for my home work it is, How do i change file permissions in a command line enviromet thanx (1 Reply)
Discussion started by: Cube3k
1 Replies
Login or Register to Ask a Question