Hi everyone,
I'm trying to get the first and last strings of a process from the result of a ps -ef command in AIX. For example, if I do a ps -ef|grep java, here's one of the results: (I'll spare you the rest of them )
was_coo 29212 1 0 Jun 11 pts/2 0:00 /bin/sh /usr/WebSphere/AppServer5/bin/launchClient.sh /usr/bsiapps/coonuans/ear/CooNuans.ear -CCBootstrapPort=2816 -CCclasspath=/usr/bsiapps/coonuans/resources:/usr/bsiapps/coo/resources:/usr/mqm/java/lib/com.ibm.mq.jar:/usr/mqm/java/lib/com.ibm.mqjms.jar:/usr/mqm/java/lib/connector.jar:/usr/mqm/java/lib/jms.jar:usr/mqm/java/lib/jndi.jar:/usr/mqm/java/lib/jta.jar:/usr/mqm/java:/usr/WebSphere/AppServer5/lib/websphere.jar:/usr/WebSphere/AppServer5/lib/ujc.jar:/usr/mqm/java/lib/com.ibm.mq.jar:/usr/mqm/java/lib/com.ibm.mqjms.jar:/usr/mqm/java/lib/connector.jar:/usr/mqm/java/lib/jms.jar:usr/mqm/java/lib/jndi.jar:/usr/mqm/java/lib/jta.jar:/usr/mqm/java:/usr/WebSphere/AppServer5/lib/websphere.jar:/usr/WebSphere/AppServer5/lib/ujc.jar:/usr/mqm/java/lib/com.ibm.mq.jar:/usr/mqm/java/lib/com.ibm.mqjms.jar:/usr/mqm/java/lib/connector.jar:/usr/mqm/java/lib/jms.jar:usr/mqm/java/lib/jndi.jar:/usr/mqm/java/lib/jta.jar:/usr/mqm/java:/usr/WebSphere/AppServer5/lib/websphere.jar:/usr/WebSphere/AppServer5/lib/ujc.jar:/usr/mqm/java/lib/com.ibm.mq.jar:/usr/mqm/java/lib/com.ibm.mqjms.jar:/usr/mqm/java/lib/connector.jar:/usr/mqm/java/lib/jms.jar:usr/mqm/java/lib/jndi.jar:/usr/mqm/java/lib/jta.jar:/usr/mqm/java:/usr/WebSphere/AppServer5/lib/websphere.jar:/usr/WebSphere/AppServer5/lib/ujc.jar:/home/dbclient/sqllib/java/db2java.zip:/home/dbclient/sqllib/java/db2jcc.jar:/home/dbclient/sqllib/function:/home/dbclient/sqllib/java/db2jcc_license_cu.jar:. -CCjar=CooNuansMonitorAppClient.jar
So in this example, I would like to change my ps -ef|grep java to something like ps -ef|grep java|awk '{print $1" "$2}' to get
was_coo 29212
but I also want the last word in the line so that the returned result would be something like
was_coo 29212 -CCjar=CooNuansMonitorAppClient.jar
Also keep in mind that some of the ps -ef results are so long that the end is truncated. (In AIX anyway). I've thought of using "cut" but I can't find how to specify the last position and work back from there.
Anyone have any ideas? Any help would be greatly appreciated.
I'm trying to get the first and last strings of a process from the result of a ps -ef command in AIX. For example, if I do a ps -ef|grep java, here's one of the results: (I'll spare you the rest of them )
was_coo 29212 1 0 Jun 11 pts/2 0:00 /bin/sh /usr/WebSphere/AppServer5/bin/launchClient.sh /usr/bsiapps/coonuans/ear/CooNuans.ear -CCBootstrapPort=2816 -CCclasspath=/usr/bsiapps/coonuans/resources:/usr/bsiapps/coo/resources:/usr/mqm/java/lib/com.ibm.mq.jar:/usr/mqm/java/lib/com.ibm.mqjms.jar:/usr/mqm/java/lib/connector.jar:/usr/mqm/java/lib/jms.jar:usr/mqm/java/lib/jndi.jar:/usr/mqm/java/lib/jta.jar:/usr/mqm/java:/usr/WebSphere/AppServer5/lib/websphere.jar:/usr/WebSphere/AppServer5/lib/ujc.jar:/usr/mqm/java/lib/com.ibm.mq.jar:/usr/mqm/java/lib/com.ibm.mqjms.jar:/usr/mqm/java/lib/connector.jar:/usr/mqm/java/lib/jms.jar:usr/mqm/java/lib/jndi.jar:/usr/mqm/java/lib/jta.jar:/usr/mqm/java:/usr/WebSphere/AppServer5/lib/websphere.jar:/usr/WebSphere/AppServer5/lib/ujc.jar:/usr/mqm/java/lib/com.ibm.mq.jar:/usr/mqm/java/lib/com.ibm.mqjms.jar:/usr/mqm/java/lib/connector.jar:/usr/mqm/java/lib/jms.jar:usr/mqm/java/lib/jndi.jar:/usr/mqm/java/lib/jta.jar:/usr/mqm/java:/usr/WebSphere/AppServer5/lib/websphere.jar:/usr/WebSphere/AppServer5/lib/ujc.jar:/usr/mqm/java/lib/com.ibm.mq.jar:/usr/mqm/java/lib/com.ibm.mqjms.jar:/usr/mqm/java/lib/connector.jar:/usr/mqm/java/lib/jms.jar:usr/mqm/java/lib/jndi.jar:/usr/mqm/java/lib/jta.jar:/usr/mqm/java:/usr/WebSphere/AppServer5/lib/websphere.jar:/usr/WebSphere/AppServer5/lib/ujc.jar:/home/dbclient/sqllib/java/db2java.zip:/home/dbclient/sqllib/java/db2jcc.jar:/home/dbclient/sqllib/function:/home/dbclient/sqllib/java/db2jcc_license_cu.jar:. -CCjar=CooNuansMonitorAppClient.jar
So in this example, I would like to change my ps -ef|grep java to something like ps -ef|grep java|awk '{print $1" "$2}' to get
was_coo 29212
but I also want the last word in the line so that the returned result would be something like
was_coo 29212 -CCjar=CooNuansMonitorAppClient.jar
Also keep in mind that some of the ps -ef results are so long that the end is truncated. (In AIX anyway). I've thought of using "cut" but I can't find how to specify the last position and work back from there.
Anyone have any ideas? Any help would be greatly appreciated.