jumping from one line to another


 
Thread Tools Search this Thread
Operating Systems Solaris jumping from one line to another
# 8  
Old 11-14-2010
Code:
awk -F"[=() ]" '
{
  if(NR==1) cur=$1
  if (cur != $1)
  {
      for(host in H) print cur,host,H[host];
      delete H;
      cur=$1;
  }
  for (i=1;i<=NF;i++) if ($i == "HOST") H[$(i+1)]++;
}
END { for(host in H) print cur,host,H[host] }' logfile

# 9  
Old 11-14-2010
Code:
awk -F'[(=)]' '{for(i=0;++i<=NF;){if($i=="HOST"){_[$1 OFS $(i+1)]++}}}END{for(i in _)print i,_[i]}' file

# 10  
Old 11-14-2010
Code:
sed 's|(.*HOST=\([^)]*\).*|\1|' input

Code:
[ctsgnb@shell ~]$ echo '24-APR-2009 (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=<service_name>)(CID=(PROGRAM=root)(HOST=<host_name>)(U SER=rock)))' | sed 's|(.*HOST=\([^)]*\).*|\1|'
24-APR-2009 <host_name>
[ctsgnb@shell ~]$

# 11  
Old 11-14-2010
danmero, could put ' ' in -F list to avoid double space in output, result is not in date order - might need to sorting it after.
ctsgnb, no count, if more that 1 "HOST=" on line only first is output.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 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

Bash script jumping too quickly to the next command - crash

Hi, (I am not too good in command-lines). I am running a bash script and at some point my loop starts to run super quickly. Then, the steps after do not get processed and there is no further outpout generated. I tried with the sleep 20s option, as I thought some steps would get overlapped, but... (22 Replies)
Discussion started by: tremblayemilie9
22 Replies

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

4. BSD

Jumping from Solaris to BSD?

Hi all, I currently run an OpenSolaris (b134) server at home for share media between a few computers (all Macs at the moment). I use ZFS to mirror a couple of disks and have a couple of SMF manifests. My background is as a user of OS X and as a user of (Open)Solaris with formal training in... (7 Replies)
Discussion started by: forquare
7 Replies

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

6. Programming

Jumping to a particular line in a file

Hi, I have an output file which has more than 1,000,000,000 lines. I am accessing this file in another C++ program. Now while accessing the output file using cin, I want to jump, say, to the 5,000,000th line directly and start accessing data from there. Is this possible? Could someone please... (4 Replies)
Discussion started by: mugga
4 Replies

7. Shell Programming and Scripting

work area directory jumping script?

hi all, Ive been trying to find some way of doing this for ages but i have is a shell script that activates a python search and there it no tab completion. more familliar with tcsh at the moment but i'm a newbe. i was trying to make an easy way to browse to a list of working directories. ... (0 Replies)
Discussion started by: jvan
0 Replies

8. Shell Programming and Scripting

script to loop and check jumping seq.

Hi, Normally, I will manually to use "ll" command to list the following file from \FILE\CACHE\ directory and check the jump seq. Can I write a script to loop or/and check jump seq file (if jumped seq and show "missing seq no" message for me) -rw-rw----+ 1 user develop 14012 Sep 4... (1 Reply)
Discussion started by: happyv
1 Replies

9. Programming

jumping to a specific line in a text file

hi everybody! i need to read a specific line from a text file using C. can any one suggest how to do it. i m aware abt fread(), fwrite(), fseek()... but using these allows the pointer to be moved 1 character at a time. Is there a way i could jump directly to a line if i know the line number?... (4 Replies)
Discussion started by: mridula
4 Replies

10. Shell Programming and Scripting

Jumping to next line with awk

I am defining an awk function (Solaris v8 ksh) of: function firstletter { echo "$line" | awk '{get=substr($1,1,1);print get}' | read FL } I am starting a wile loop with a: for line in `cat inputfile.lst` When I call the function from within the for loop it works great fine. From within... (4 Replies)
Discussion started by: gozer13
4 Replies
Login or Register to Ask a Question