Spilt the line into two....


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Spilt the line into two....
# 15  
Old 09-08-2009
MySQL

thats precisely what i am asking....

the command/ set of commands to capture that string?

In case you have an AIX box,run following command

Code:
COLUMNS=2047 /usr/bin/ps -eo pid,ppid,uid,user,args

You'll see five-column o/p ,of which 5th column will have strings ,separated by whitespaces.

Select one row where 5th column would be a such a huge string.Now assume you are iterating over its PID(1st column value) meaning you know this value and need to iterate over this to get that 5th column and whatever is there in that column ,assign it to a variable.

How would ya do it?

Regards
Abhi
# 16  
Old 09-08-2009
Quote:
Originally Posted by ak835
...
In case you have an AIX box,run following command

Code:
COLUMNS=2047 /usr/bin/ps -eo pid,ppid,uid,user,args

You'll see five-column o/p ,of which 5th column will have strings ,separated by whitespaces.
Why don't you paste the output of that command over here ?
Not everyone over here has an AIX box (an example being myself).

Quote:
Select one row where 5th column would be a such a huge string.Now assume you are iterating over its PID(1st column value) meaning you know this value ...
Which value ? 5th column or 1st column ?

Quote:
... and need to iterate over this to get that 5th column ...
Does "this" mean the "1st column" ?
Why would one need to iterate over the "1st column" ?

Quote:
... and whatever is there in that column ,assign it to a variable.
Again, what's "that column" ? - 5th column ? or (gasp!) 1st column ?

tyler_durden
# 17  
Old 09-09-2009
Error

puff!!

i thought ppl here are smart enough to understand things....!! sheer disappointment !!

one last attempt to explain what i need:

here it is

Code:
bash-3.00$ COLUMNS=2047 /usr/bin/ps -eo pid,ppid,uid,user,args
238062      1     0     root /opt/CA/SharedComponents/ca_lic/lic98fds

242070 131238     0     root /var/itlm/wasagent/jre/bin/java -classpath properties:lib/admin.jar:lib/bootstrap.jar:lib/classloader.jar:lib/ecutils.jar:lib/emf.jar:lib/ffdc.jar:lib/idl.jar:lib/iwsorb.jar:lib/j2ee.jar:lib/mail-impl.jar:lib/management.jar:lib/naming.jar:lib/namingclient.jar:lib/ras.jar:lib/runtime.jar:lib/sas.jar:lib/security.jar:lib/soap.jar:lib/tmx4jc.jar:lib/tx.jar:lib/utils.jar:lib/wasjmx.jar:lib/wasproduct.jar:lib/wlmclient.jar:lib/wsexception.jar:lib/wssec.jar:wasagent.jar:resources.jar:jlog.jar:jffdc.jar:tivolicommondir.jar:ITLMToolkit.jar -Djlog.propertyFileDir=/var/itlm/wasagent -Ditlm.agent.dir=/var/itlm -Dcom.ibm.SOAP.ConfigURL=file:/var/itlm/wasagent/properties/soap.client.props -Djava.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory -Ditlm.config.dir=/etc -Ditlm.agent.pid=131238 com.ibm.it.rome.wasagent.WASAgent

246220 299054     0     root db2ckpwd 0

now we see PID column,we have that value.Take that value and write something that it would look for the 5th column (command)...and irrespective of how long this string (command) is ,assign it to a variable.

e.g PID=242070,ARGS string is needed in a variable so that i can spilt it into three parts.(Command Name,Command Path,Command Arguments)


Regards
Abhi

---------- Post updated at 06:03 PM ---------- Previous update was at 04:00 PM ----------

Code:
PID  @@Host Processes .PID@@
COLUMNS=2047 ps -eo pid,ppid,uid,user,args|awk -F' ' '{ if($1 == @@Host Processes.PID@@) print $5 }'

If i punch "242070" in place of @@Host Processes.PID@@,then what i get is
Code:
/var/itlm/wasagent/jre/bin/java

I need that whole string.

Does this help?

Regards
Abhi

---------- Post updated at 06:06 PM ---------- Previous update was at 06:03 PM ----------

oops !! i again spoke in riddle.....didn't i ?!!

Code:
I need that whole string.

that whole string is:

Code:
/var/itlm/wasagent/jre/bin/java -classpath properties:lib/admin.jar:lib/bootstrap.jar:lib/classloader.jar:lib/ecutils.jar:lib/emf.jar:lib/ffdc.jar:lib/idl.jar:lib/iwsorb.jar:lib/j2ee.jar:lib/mail-impl.jar:lib/management.jar:lib/naming.jar:lib/namingclient.jar:lib/ras.jar:lib/runtime.jar:lib/sas.jar:lib/security.jar:lib/soap.jar:lib/tmx4jc.jar:lib/tx.jar:lib/utils.jar:lib/wasjmx.jar:lib/wasproduct.jar:lib/wlmclient.jar:lib/wsexception.jar:lib/wssec.jar:wasagent.jar:resources.jar:jlog.jar:jffdc.jar:tivolicommondir.jar:ITLMToolkit.jar -Djlog.propertyFileDir=/var/itlm/wasagent -Ditlm.agent.dir=/var/itlm -Dcom.ibm.SOAP.ConfigURL=file:/var/itlm/wasagent/properties/soap.client.props -Djava.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory -Ditlm.config.dir=/etc -Ditlm.agent.pid=131238 com.ibm.it.rome.wasagent.WASAgent

# 18  
Old 09-09-2009
try something like this :

Code:
awk .............{ for(i=5;i<=NF;i++) print $i } '  .. instead of "print $5"

# 19  
Old 09-09-2009
One way:

Code:
COLUMNS=2047 /usr/bin/ps -eo pid,ppid,uid,user,args |
awk '/java/{$1=$2=$3=$4="";sub("^    ","");print}'

Regards
# 20  
Old 09-11-2009
MySQL

Thanks panyam ..!!
that for loop works ..just that it eats up whitespaces !!

Thanks Franklin52 !!
awk with sub worked well in AIX and Linux... had to use 'substr' in solaris...!!

Watch out my threads in near future... i have got some nasty request to be done with !!

Thank you everyone !!

Regards
Abhi
# 21  
Old 11-17-2009
Join lines in a file between <record> and </record> tags and there are many tags

Hi,
Can you please help with reading a file and formatting it by removing the new lines between <record> and </record? tags.

The input file is as below:
<record>123
xxxxx
<abc>
</record>
<record>456
yyyy
<xxx>
</record>

the expected output is:
<record>123xxxxx<abc></record>
<record>456yyyy<xxx></record>

Thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. 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

2. 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

3. Shell Programming and Scripting

Need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line...

Hello, I need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line... An example of entries in the file would be: SRVXPAPI001 ERRO JUN24 07:28:34 1775 REASON= 0000, PROCID= #E506 #1065: TPCIPPR, INDEX= 003F ... (8 Replies)
Discussion started by: Ferocci
8 Replies

4. Shell Programming and Scripting

sed command to replace a line at a specific line number with some other line

my requirement is, consider a file output cat output blah sdjfhjkd jsdfhjksdh sdfs 23423 sdfsdf sdf"sdfsdf"sdfsdf"""""dsf hellow there this doesnt look good et cetc etc etcetera i want to replace a line of line number 4 ("this doesnt look good") with some other line ... (3 Replies)
Discussion started by: vivek d r
3 Replies

5. Shell Programming and Scripting

how to read the contents of two files line by line and compare the line by line?

Hi All, I'm trying to figure out which are the trusted-ips and which are not using a script file.. I have a file named 'ip-list.txt' which contains some ip addresses and another file named 'trusted-ip-list.txt' which also contains some ip addresses. I want to read a line from... (4 Replies)
Discussion started by: mjavalkar
4 Replies

6. Shell Programming and Scripting

[Solved] Problem in reading a file line by line till it reaches a white line

So, I want to read line-by-line a text file with unknown number of files.... So: a=1 b=1 while ; do b=`sed -n '$ap' test` a=`expr $a + 1` $here do something with b etc done the problem is that sed does not seem to recognise the $a, even when trying sed -n ' $a p' So, I cannot read... (3 Replies)
Discussion started by: hakermania
3 Replies

7. AIX

How to spilt huge string in AIX ?

I have few AIX 5.3 boxes where following is the issue. I have a variable whose value is a very huge string ...(5000+ characters) CMD_ARGS="/global/site/vendor/WAS/WebSphere6/AppServer/java/bin/java... (7 Replies)
Discussion started by: ak835
7 Replies

8. Shell Programming and Scripting

How to spilt a file

Hi , I have a file,abc.txt. like abc.txt ======= KOKRS EL01 RLDNR M2 RRCTY 1 Company Code 100 ... (8 Replies)
Discussion started by: deep_kol
8 Replies

9. Shell Programming and Scripting

Spilt excel file in unix

Hi friends... I am sending a file say xyz.xls to a mail through unix. The .xls file is more than 65 thousand in size so I want to spilt the file size into 40 thousand and 25 thousand. So can anyone provide any inputs.... (1 Reply)
Discussion started by: Soumya Dash
1 Replies
Login or Register to Ask a Question