Sponsored Content
Top Forums Shell Programming and Scripting awk find and print next string Post 302885223 by Akshay Hegde on Friday 24th of January 2014 08:32:04 AM
Old 01-24-2014
Sorry I thought you want only PID

Code:
$ echo "Start: 12345 is used by PID:11111 username" | awk  'gsub(/.*PID:/,x)'
11111 username

Code:
$ echo "Start: 12345 is used by PID:11111 username" | awk  '{split($0,A,"PID:");print A[2]}'
11111 username

Code:
$ echo "Start: 12345 is used by PID:11111 username" | awk -F"PID:" '{print $2}'
11111 username

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Unix find command to print directory and search string

Hi i need to print pathname in which the string present using 'find' command sample output like this Pathname String to be searched ---------- -------------------- /usr/test/myfile get /opt/test/somefile get Thanks in... (4 Replies)
Discussion started by: princein
4 Replies

2. UNIX for Dummies Questions & Answers

AWK...find a string ,if so print it

Hi, I need to find a string, if it finds then I need to print it , otherwise it has to goto next line.... input is====> uid = shashi, india uid ,uid= asia uid= none, uid=india. none ========== output shold be uid = shashi, india uid , uid= asia uid= none, uid=india. none ... (1 Reply)
Discussion started by: hegdeshashi
1 Replies

3. Shell Programming and Scripting

Perl : Find a string and Print full line

Hi Need a perl script to read lines in a file, scan for a string named "APPLE" and write to different file the only lines containing the matched string. (5 Replies)
Discussion started by: PrasannaKS
5 Replies

4. Shell Programming and Scripting

awk find a string, print the line 2 lines below it

I am parsing a nagios config, searching for a string, and then printing the line 2 lines later (the "members" string). Here's the data: define hostgroup{ hostgroup_name chat-dev alias chat-dev members thisisahostname } define hostgroup{ ... (1 Reply)
Discussion started by: mglenney
1 Replies

5. Shell Programming and Scripting

Find a string using grep & print the line above or below that.

Hi All, Please tell me how can I Find a string using grep & print the line above or below that in solaris? Please share as I am unable to use grep -A or grep -B as it is not working on Solaris. (10 Replies)
Discussion started by: Zaib
10 Replies

6. Shell Programming and Scripting

Awk - find string, search lines below string for other strings

What's the easiest way to search a file for a specific string and then look for other instances after that? I want to search for all Virtual Hosts and print out the Server Name and Document Root (if it has that info), while discarding the rest of the info. Basically my file looks like this: ...... (6 Replies)
Discussion started by: Mbohmer
6 Replies

7. Shell Programming and Scripting

Find longest string and print it

Hello all, I need to find the longest string in a select field and print that field. I have tried a few different methods and I always end up one step from where I need to be. Methods thus far: nawk '{if (length($1) > long) long=length($1); if(length($1)==long) print $1}' The above... (6 Replies)
Discussion started by: SEinT
6 Replies

8. UNIX for Dummies Questions & Answers

find string and and print another string

i have a file that looks like this ABC123 aaaaaaaaaaaaaaasssssssssssssssffhhh ABC234 EMPTY ABC652 jhfffffffffffffffffffffffffffffffffffkkkkkkkkkkkk i want to grep "EMPTY" and print ABC234 (3 Replies)
Discussion started by: engr.jay
3 Replies

9. Programming

Find and print number after string in C

I'm trying find and print a number after a specific user passed string in each line of a text file using C (as requested by the powers that be). I've pieced together enough to read the file, find the string and print the line it was found on but I’m not sure where to even start in terms of finding... (3 Replies)
Discussion started by: cgol
3 Replies

10. Shell Programming and Scripting

Find a string and print all lines upto another string

Ok I would like to do the following file test contains the following lines. between the lines ABC there may be any amount of lines up to the next ABC entry. I want to grep for the filename.txt entry and print the lines in between (and including that line) up to and including the last line... (3 Replies)
Discussion started by: revaroo
3 Replies
RDS-GEN-SINK(1) 					    BSD General Commands Manual 					   RDS-GEN-SINK(1)

NAME
rds-gen -- write data from a file to an RDS socket rds-sink -- write data from an RDS socket to a file SYNOPSIS
rds-gen [-s source_address:source_port] [-d destination_address:destination_port] [-f input_file] [-m message_size] [-l total_bytes] [-i interval] rds-sink [-s listen_address:listen_port] [-f output_file] [-i interval] DESCRIPTION
The rds-gen and rds-sink utilities are used to stream data through RDS sockets. rds-gen reads data from a file descriptor and sends it as messages down an RDS socket. rds-sink receives messages from an RDS socket and writes it to a file descriptor. The following options are shared between rds-gen and rds-sink: -s address:port Binds the RDS socket to the given address and port. rds-gen will send messages from this address and port. rds-sink will receive messages sent to this address and port. -f file rds-gen will read data from this file and rds-sink will write data to this file. If '-' is given as the filename then rds-gen will use standard input and rds-sink will use standard output. -i interval_seconds An iterative summary of the number and size of messages that are sent and received is written to standard error at this interval. In addition, rds-gen supports the following options: -d address:port Messages are sent to this destination address and port. If this option is specified multiple times then the messages are sent to each destination address in a round-robin fashion. -m message_size Specifies the size of the messages that are sent down the RDS socket. The default message size is 4k. The message size must not be greater than the buffer size. -l total_bytes Specifies the number of bytes that will be sent out the socket before rds-gen exits. If this is not specified and rds-gen was given a source file then it will run until it gets EOF from the file. If no file was given and this option is not specified then rds-gen will send data indefinitely. EXAMPLES
rds-gen on host src sends infinite data to rds-sink on dest who prints out the amount of data it receives every second. $ rds-sink -s dest:22222 -i 1 $ rds-gen -s src:11111 -d dest:22222 Read 100M from /dev/zero on src and write it to /dev/null on dest, printing stats on both sides every minute. $ rds-sink -s dest:22222 -f /dev/null -i 60 $ rds-gen -s src:11111 -f /dev/zero -d dest:22222 -i 60 Watch rds-gen write data as fast as it can into a local black hole because there is no bound receiving socket. $ rds-gen -s src:11111 -d localhost:31337 -i 1 BSD
October 30, 2006 BSD
All times are GMT -4. The time now is 02:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy