Sponsored Content
Top Forums Shell Programming and Scripting Piping STDOUT as pattern to grep or sed Post 302305572 by nobody4 on Thursday 9th of April 2009 08:59:16 AM
Old 04-09-2009
Re: Piping STDOUT as pattern to grep or sed

egrep has (and some greps have) an option to read the patterns from a file.

If your OS (like Solaris) provides a mechanism to access
file descriptors as filenames, one can use this to read file descriptor 0 (stdin)
for the patterns.


<some command> | egrep -f /dev/fd/0 filename
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep and sed to find a pattern and add newline

Hello All, I have log file the result from a multithreaded process. So when a process finishes it will write to this log file as 123 rows merged. The issue is sometimes the processess finish at the same time or write to the file at the same time as 123 rows merged.145 rows merged. At... (5 Replies)
Discussion started by: ssikhar
5 Replies

2. Shell Programming and Scripting

Extracting pattern only with AWK | SED | GREP

We have the following statement working in CGYWIN, but when we move the program to Solaris 10 it fails. x=`echo "ABC196925XYZ" | grep -o --only-matching "\{6\}"` How can we use AWK or SED to extract only the number from the string? The following outputs the entire string. We only want... (5 Replies)
Discussion started by: James Clark
5 Replies

3. Shell Programming and Scripting

How to awk/sed/grep lines which contains a pattern at a given position

Dear friends I am new to linux and was trying to split some files userwise in our linux server. I have a data file of 156 continuous columns named ecscr final. I want the script to redirect all the lines containing a pattern of 7 digits to separate files. I was using grep to do that,... (2 Replies)
Discussion started by: anoopvraj
2 Replies

4. Shell Programming and Scripting

SED equivalent for grep -w -f with pattern having special characters

I'm looking for SED equivalent for grep -w -f. All I want is to search a list of patterns from a file. Also If the pattern doesn't match I do not want "null returned", rather I would prefer some text as place holder say "BLANK LINE" as I intend to process the output file based on line number. ... (1 Reply)
Discussion started by: novice_man
1 Replies

5. Shell Programming and Scripting

Help to search multiple pattern in file with grep/sed/awk

Hello All, I have a file which is having below type of data, Jul 19 2011 | 123456 Jul 19 2011 | 123456 Jul 20 2011 | 123456 Jul 20 2011 | 123456 Here I wanted to grep for date pattern as below, so that it should only grep "Jul 20" OR "Jul ... (9 Replies)
Discussion started by: gr8_usk
9 Replies

6. UNIX for Dummies Questions & Answers

One liner pattern search with awk/sed/grep

I have an array containing bunch of characters. I have to check this array for specific character and if "Not Found than" use a goto statement to go to USAGE set options = (A B C D E F) @ i = 0 while ($i <= ${#options}) if ($options != "F" || $options != "D") then goto USAGE endif @... (1 Reply)
Discussion started by: dixits
1 Replies

7. Shell Programming and Scripting

How to print the lines between the pattern using awk/grep/sed?

Hi, I need a help to search a pattern and print the multiple lines between them. Input file: Tue May 29 12:30:33 EDT 2012:threadWebContainer : 357:com.travimp.hotelierlinks.abba.service.RequestHandler.requestService(String, ITICSDataSet): hotelCancelReservation request: ... (4 Replies)
Discussion started by: aroragaurav.84
4 Replies

8. Shell Programming and Scripting

Sed/awk : to grep only required pattern disk

Hi Experts, Need help with the following: Desired output: Only want to get the output marked in green. The file: --- Physical volumes --- PV Name /dev/disk/disk4704 PV Status available Total PE 6399 Free PE ... (3 Replies)
Discussion started by: rveri
3 Replies

9. UNIX for Dummies Questions & Answers

Piping grep into awk, read the next line using grep

Hi, I have a number of files containing the information below. """"" Fundallinfo 6.3950 14.9715 14.0482 """"" I would like to grep for Fundallinfo and use it to read the next line? I ideally would like to read the three numbers that follow in the next line and... (2 Replies)
Discussion started by: Paul Moghadam
2 Replies

10. Shell Programming and Scripting

sed and awk usage to grep a pattern 1 and with reference to this grep a pattern 2 and pattern 3

Hi , I have a file where i have modifed certain things compared to original file . The difference of the original file and modified file is as follows. # diff mir_lex.c.modified mir_lex.c.orig 3209c3209 < if(yy_current_buffer -> yy_is_our_buffer == 0) { --- >... (5 Replies)
Discussion started by: breezevinay
5 Replies
AUTHOPEN(1)						    BSD General Commands Manual 					       AUTHOPEN(1)

NAME
authopen -- open file with authorization SYNOPSIS
authopen [-stdoutpipe] [-extauth] filename authopen [-stdoutpipe] [-extauth] -w [-a] filename authopen [-stdoutpipe] [-extauth] -c [-x -m mode -w] filename authopen [-stdoutpipe] [-extauth] -o flags filename authopen -h DESCRIPTION
authopen provides authorization-based file opening services. In its simplest form, authopen verifies that it is allowed to open filename (using an appropriate sys.openfile.* authorization right) and then writes the file to stdout. If -w is specified, authopen will read from stdin and write to the file. authopen is designed to be used both from the command line and programmatically. The -stdoutpipe flag allows a parent process to receive an open file descriptor pointing to the file in question. Before opening filename, authopen will make an authorization request for a right of the form: sys.openfile.[readonly|readwrite|readwritecreate]./fully/qualified/path '.readonly' rights only allow for read-only file descriptors. '.readwrite' rights allow for read/write file descriptors. '.readwritecreate' rights allow for read/write descriptors and the creation of new files. The -extauth option can be used to provide an AuthorizationRef constructed by the client. This generally prevents authopen from presenting an authorization dialog containing its own name. OPTIONS
-stdoutpipe specifies that STDOUT_FILENO has been dup2()'d onto a pipe to a parent process and that an open file descriptor to filename (with the appropriate access mode) should be sent back across it using the SCM_RIGHTS extension to sendmsg(2) rather than having the file itself written to or read from stdin / stdout. -extauth specifies that authopen should read one AuthorizationExternalForm structure from stdin, convert it to an AuthorizationRef, and attempt to use it to authorize the open(2) operation. The authorization should refer to the sys.apenfile right corresponding to the requested operation. The authorization data will be read before any additional data supplied on stdin, and will not be included in data written with -w. -w instructs authopen to open filename read/write and truncate it. If -stdoutpipe has not been specified, authopen will then copy stdin to filename until stdin is closed. -a append to filename rather than truncating it (truncating is the default). -c create the file if it doesn't exist. -m requires -c. -m mode specify the mode bits if a file is created. -o flags numerically specify the flags that should be passed to open(2). -x require that the file being created not exist. EXAMPLES
To replace /etc/hostconfig (assuming sys.openfile.readwrite./etc/hostconfig or better can be obtained): $ cat tmpdata | authopen -w /etc/hostconfig ERRORS
authopen will fail if an appropriate sys.openfile.readonly.*, sys.openfile.readwrite.*, or sys.openfile.readwritecreate.* right cannot be obtained or if the named path does not exist. BUGS
authopen should support prefix path authentication such that the right sys.openfile.*./dev/ could give access to all /dev entries and sys.openfile.*./dev/disk1 could give access to all disk1-related /dev entries. authopen should use getopt(3). LOCATION
/usr/libexec/authopen SEE ALSO
open(2), Security/Authorization.h, realpath(3), recvmsg(2). W. Richard Stevens, "Passing File Descriptors", Advanced Programming in the UNIX Environment. HISTORY
authopen appeared in Mac OS X 10.1 to assist with the manipulation of disk devices. Darwin 28 Feb 2013 Darwin
All times are GMT -4. The time now is 05:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy