Hi
I am using awk to print 10,11 column but it is not displaying required output.
Please let me know how I can browse through the line and extract the required one
This is difficult if not impossible, as you have spaces as field separators but also contained in desired output values. Do you see a chance to define fields and separators differently?
This is difficult if not impossible, as you have spaces as field separators but also contained in desired output values. Do you see a chance to define fields and separators differently?
I tried below, but not able to remove one "("
Output
---------- Post updated at 11:13 AM ---------- Previous update was at 11:07 AM ----------
Quote:
Originally Posted by RudiC
Well, this might work, taking advantage of the data structure as shown:
The two commands:
clearly can't produce the desired output since you are printing two whitespace-separated input fields when your output contains three whitespace-separated fields. Furthermore, you have two unneeded invocations of cat, egrep, and uniq; one unneeded invocation of awk and one or two unneeded invocations of sort.
The following is an alternative to the code RudiC suggested that seems to do what you want with one invocation of awk and one invocation of sort:
which (if file contains one or more copies of the three sample input lines you showed us in post #1) produces the output:
which contains a space separating the two input fields that make up the "1st column" output and a tab separating that from the single output field that makes up the "2nd column" output.
If you don't care about the order of lines in the output (and were just using sort | uniq to get rid of duplicate lines of output instead of caring about the order of the output, delete the text in the script shown in red and it will run a little bit faster.
If you are trying this on a Solaris/SunOS system, change awk in the script to /usr/xpg4/bin/awk or nawk.
It isn't clear to me whether you actually want those headings or not, but I included them since that is what you said you wanted. I assume that it is obvious that you can remove the printf statement from my script above if you don't want the heading line in your output.
Hi all,
I have script to monitor and sum up the total memory use up for each individual process.
proc=$1
svmon -P -O summary=basic,unit=MB|awk 'NR>4'|grep -w "${proc}" |awk '{sum+=$3} END {printf "\t" sum """\n";}'
But I would like the script to be able to display as following
... (3 Replies)
Hi
I know sed and awk has options to give range of line numbers, but
I need to replace pattern in specific lines
Something like
sed -e '1s,14s,26s/pattern/new pattern/' file name
Can somebody help me in this....
I am fine with see/awk/perl
Thank you in advance (9 Replies)
Hi
I am using the following command to look for anything other than
"0000" in a comma seperated file on 11th field.
Note: I am looking for "0000" including the double quotes.
nawk -F"," '$11!='"0000"'{print $11}' file
This is showing incorrect result.
Help is appreciated (2 Replies)
Hi,
When we have a failure, sometimes we just step restart the job from the next step. Later when we open the log for analysis of the failure, it is becoming difficult to go to the failure part.
For eg., if it is a 1000 line log, the failure may be at 500th line. so wat i want to do is, grep... (6 Replies)
Hi,
I wish to use a column, as inputted by a user from command line, for pattern matching.
awk file:
{
if($1 ~ /^8/)
{
print $0> "temp2.csv"
}
}
something like this, but i want '$1' to be any column as selected by the user from command line.
... (1 Reply)
Hi,
I have a requirement for taking an particular number in a log file. if i grep for the particular string it will retrieve the entire line for the particular string. but i want to display only the string from each line which i am searching for,
Note: The searching field varies its position... (3 Replies)
Hi,
I have a file with 500 Lines and I want to search for a pattern within this file which starts with sm_ and ends with ). However I just want to print the pattern only and not the entire line. How do I do it ?
Thanks,
p (5 Replies)