Sponsored Content
Top Forums UNIX for Beginners Questions & Answers How do I redirect output from "find", either to a file or another command? Post 303043900 by vbe on Monday 10th of February 2020 01:29:33 PM
Old 02-10-2020
OK I see we could have some misunderstanding: I suggest you document yourself on special files, file descriptors, and what I mentionned above related to named pipes... In order to understand what I thrown at you ( thus know how to create them...) I suppose a little reading on what and how to use FIFOs may be far from beeing a waste of time...
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

the operato < for redirect output "inverse"....

see this cat < Files return the cointent of Files but cat files return the same result WHI??? this command lp -f """PRINTER" < cat files not print the content of files (1 Reply)
Discussion started by: ZINGARO
1 Replies

2. Shell Programming and Scripting

"find command" to find the files in the current directories but not in the "subdir"

Dear friends, please tell me how to find the files which are existing in the current directory, but it sholud not search in the sub directories.. it is like this, current directory contains file1, file2, file3, dir1, dir2 and dir1 conatins file4, file5 and dir2 contains file6,... (9 Replies)
Discussion started by: swamymns
9 Replies

3. Shell Programming and Scripting

store the output of "find" command in a variable?

I intend to find the path/full location of a file(filename given by user thru "read filenme") using "find" or any other command and then store it's output in a variable for some other processing. But struggling to put all things together (i.e finding the fully qualified location of that file and... (4 Replies)
Discussion started by: punitpa
4 Replies

4. UNIX for Dummies Questions & Answers

Explanation of "total" field in "ls -l" command output

When I do a listing in one particular directory (ls -al) I get: total 43456 drwxrwxrwx 2 root root 4096 drwxrwxrwx 3 root root 4096 -rwxrwxr-x 1 nobody nobody 3701594 -rwxrwxr-x 1 nobody nobody 3108510 -rwxrwxr-x 1 nobody nobody 3070580 -rwxrwxr-x 1 nobody nobody 3099733 -rwxrwxr-x 1... (1 Reply)
Discussion started by: proactiveaditya
1 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Shell Programming and Scripting

Problem with "find" and "grep" command

I want to list all files/lines which except those which contain the pattern ' /proc/' OR ' /sys/' (mind the leading blank). In a first approach I coded: find / -exec ls -ld {} | grep -v ' /proc/| /sys/' \; > /tmp/list.txt But this doesn't work. I got an error (under Ubuntu): grep:... (5 Replies)
Discussion started by: pstein
5 Replies

7. Shell Programming and Scripting

Using a single "find" cmd to search for multiple file types and output individual files

Hi All, I am new here but I have a scripting question that I can't seem to figure out with the "find" cmd. What I am trying to do is to only have to run a single find cmd parsing the directories and output the different file types to induvidual files and I have been running into problems.... (3 Replies)
Discussion started by: swaters
3 Replies

8. Shell Programming and Scripting

What is the right way to redirect script output use ">" or ">>" ?

Which one of the following are more accurate and why? nohup myScript.sh 1>nohup_$(date +%Y%m%d%H%M%S).out 2>&1 & nohup myScript.sh 1>>nohup_$(date +%Y%m%d%H%M%S).out 2>&1 & nohup myScript.sh >nohup_$(date +%Y%m%d%H%M%S).out 2>&1 & nohup myScript.sh >>nohup_$(date +%Y%m%d%H%M%S).out 2>&1 &... (3 Replies)
Discussion started by: kchinnam
3 Replies

9. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

10. Programming

Redirecting output to new file for command "perldoc perllocal"

Hi, I have to redirect output of the command "perldoc perllocal" to new file which contains all the perl module installed. Currently using perldoc perllocal >> mod_data This does not contain all perl modules installed locally on machine, and each character is doubled. Please... (3 Replies)
Discussion started by: asak
3 Replies
select(2)							System Calls Manual							 select(2)

NAME
select(), pselect(), FD_CLR(), FD_ISSET(), FD_SET(), FD_ZERO() - synchronous I/O multiplexing SYNOPSIS
For Backward Compatibility Only: (_XOPEN_SOURCE_EXTENDED not defined) DESCRIPTION
The and functions indicate which of the specified file descriptors is ready for reading, ready for writing, or has an error condition pend- ing. If the specified condition is false for all of the specified file descriptors, and block, up to the specified timeout interval, until the specified condition is true for at least one of the specified file descriptors. The and functions support regular files, terminal and pseudo-terminal devices, STREAMS-based files, FIFOs and pipes. The behaviour of and on file descriptors that refer to other file types is unspecified. The nfds argument specifies the range of file descriptors to be tested. The and functions test file descriptors in the range of 0 to nfds -1. File descriptor f is represented by the bit 1<<f in the masks. More formally, a file descriptor is represented by: If the readfds argument is not a null pointer, it points to an object of type fd_set that on input specifies the file descriptors to be checked for being ready to read, and on output indicates which file descriptors are ready to read. If the writefds argument is not a null pointer, it points to an object of type fd_set that on input specifies the file descriptors to be checked for being ready to write, and on output indicates which file descriptors are ready to write. If the errorfds argument is not a null pointer, it points to an object of type fd_set that on input specifies the file descriptors to be checked for error conditions pending, and on output indicates which file descriptors have error conditions pending. On successful completion, the objects pointed to by the readfds, writefds, and errorfds arguments are modified to indicate which file descriptors are ready for reading, ready for writing, or have an error condition pending, respectively. For each file descriptor less than nfds, the corresponding bit will be set on successful completion if it was set on input and the associated condition is true for that file descriptor. If the timeout argument is not a null pointer, it specifies a maximum interval to wait for the selection to complete. The timeout argument points to an object of type for and to an object of type for If the members of these structures are 0, or will not block. If the timeout argument is a null pointer, or will block until an event causes one of the masks to be returned with a valid (non-zero) value. If the time limit expires before any event occurs that would cause one of the masks to be set to a non-zero value, or completes successfully and returns 0. Implementations may place limitations on the maximum timeout interval supported. On all implementations, the maximum timeout interval sup- ported will be at least 31 days. If the timeout argument specifies a timeout interval greater than the implementation-dependent maximum value, the maximum value will be used as the actual timeout value. Implementations may also place limitations on the granularity of time- out intervals. If the requested timeout interval requires a finer granularity than the implementation supports, the actual timeout inter- val will be rounded up to the next supported value. If sigmask is not a null pointer, then the function shall replace the signal mask of the process by the set of signals pointed to by sig- mask before examining the descriptors, and shall restore the signal mask of the process before returning. If the readfds, writefds, and errorfds arguments are all null pointers and the timeout argument is not a null pointer, or blocks for the time specified, or until interrupted by a signal. If the readfds, writefds, and errorfds arguments are all null pointers and the timeout argument is a null pointer, or blocks until interrupted by a signal. File descriptors associated with regular files always select true for ready to read, ready to write, and error conditions. On failure, the objects pointed to by the readfds, writefds, and errorfds arguments are not modified. If the timeout interval expires without the specified condition being true for any of the specified file descriptors, the objects pointed to by the readfds, writefds, and errorfds arguments have all bits set to 0. Ttys and sockets are ready for reading if a would not block for one or more of the following reasons: o input data is available. o an error condition exists, such as a broken pipe, no carrier, or a lost connection. Similarly, ttys and sockets are ready for writing if a would not block for one or more of the following reasons: o output data can be accepted. o an error condition exists, such as a broken pipe, no carrier, or a lost connection. TCP sockets select true on reads only for normal data. They do not select true on reads if out-of-band data ("urgent" data) arrives. TCP sockets select true on exceptions for out-of-band data. AF_CCITT sockets select true on reads for normal and out-of-band data and information, including supervisory frames. Pipes are ready for reading if there is any data in the pipe, or if there are no writers left for the pipe. Pipes are ready for writing if there is room for more data in the pipe AND there are one or more readers for the pipe, OR there are no readers left for the pipe. returns the same results for a pipe whether a file descriptor associated with the read-only end or the write-only end of the pipe is used, since both file descriptors refer to the same underlying pipe. So a of a read-only file descriptor that is associated with a pipe can return ready to write, even though that particular file descriptor cannot be written to. File descriptor masks of type fd_set can be initialized and tested with and It is unspecified whether each of these is a macro or a func- tion. If a macro definition is suppressed in order to access an actual function, or a program defines an external identifier with any of these names, the behaviour is undefined. Clears the bit for the file descriptor fd in the file descriptor set fdset. Returns a non-zero value if the bit for the file descriptor fd is set in the file descriptor set pointed to by fdset, and 0 otherwise. Sets the bit for the file descriptor fd in the file descriptor set fdset. Initializes the file descriptor set fdset to have zero bits for all file descriptors. The behaviour of these macros is undefined if the fd argument is less than 0 or greater than or equal to The use of a timeout does not affect any pending timers set up by or On successful completion, the object pointed to by the timeout argument of may be modified. The is used in the definition of structure. It is set to a value of 2048 to accommodate 2048 file descriptors. Any user code that uses or the structure should redefine to a smaller value (greater than or equal to the number of open files the process will have) in order to save space and execution time. Similarly, any user code that wants to test more than 2048 file descriptors should redefine to the required higher value. The user can also allocate the space for structure dynamically, depending upon the number of file descriptors to be tested. The following code segment illustrates the basic concepts. RETURN VALUE
and return no value. returns a non-zero value if the bit for the file descriptor fd is set in the file descriptor set pointed to by fdset, and 0 otherwise. On successful completion, and return the total number of bits set in the bit masks. Otherwise, -1 is returned, and is set to indicate the error. ERRORS
Under the following conditions, and fail and set to: One or more of the file descriptor sets specified a file descriptor that is not a valid open file descriptor. This could happen either if the file descriptor sets are not initialized or nfds argument is greater than The function was interrupted before any of the selected events occurred and before the timeout interval expired. If has been set for the interrupting signal, it is imple- mentation-dependent whether the function restarts or returns with One or more of the pointers was invalid. The reliable detection of this error is implementation dependent. An invalid timeout interval was specified. Valid values for the number of nanoseconds (in should be a non-negative integer less than 1,000,000,000. For the number of microseconds (in struct timeval), a non-negative integer less than 1,000,000 should be used. Seconds should be specified using a non-negative integer. The nfds argument is less than 0, or is greater than or equal to the value of which specifies the absolute maximum number of files a process can have open at one time. If the resource limit for a process is less than or equal to 2048, is considered to be 2048. One of the specified file descriptors refers to a STREAM or multiplexer that is linked (directly or indirectly) downstream from a multiplexer. EXAMPLES
The following call to checks if any of 4 terminals are ready for reading. times out after 5 seconds if no terminals are ready for reading. Note that the code for opening the terminals or reading from the terminals is not shown in this example. Also, note that this example must be modified if the calling process has more than 32 file descriptors open. Following this first example is an example of select with more than 32 file descriptors. The following example is the same as the previous example, except that it works for more than 32 open files. Definitions for and are in WARNINGS
The file descriptor masks are always modified on return, even if the call returns as the result of a timeout. DEPENDENCIES
supports the following devices and file types: o pipes o fifo special files (named pipes) o all serial devices o All ITEs (internal terminal emulators) and HP-HIL input devices o lan(7) special files o pty(7) special files o sockets AUTHOR
was developed by HP and the University of California, Berkeley. SEE ALSO
fcntl(2), poll(2), read(2), sigprocmask(2), write(2), thread_safety(5), select(2)
All times are GMT -4. The time now is 05:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy